SeriesAggreg fails on columns with units
Minimal Reproducible Example with calculation of mean temperature with units:
d <- seq.POSIXt(
from = as.POSIXct("2020-01-01 00:00:00", tz = "UTC"),
to = as.POSIXct("2021-12-31 23:59:59", tz = "UTC"),
by = "1 day"
)
df <- data.frame(d = d, v = units::as_units(rep(1, length(d)), "°C"))
QM <- SeriesAggreg(df, Format = "%Y%m", ConvertFun = "mean")
The call to SeriesAggreg
ends with: Error in [.data.frame(tsAggreg, , colnames(TabSeries0)) : undefined columns selected
The call to :
aggregate(. ~ Fac2, data = TabSeries2[, colTsAggreg],
FUN = listConvertFun[[y]], na.action = na.pass)
in SeriesAggreg.data.frame
renames the columns containing the data... One workaround could be to rename manually the columns to their original name after this call.
This issue doesn't seem to occur on sum, and it seem that column renaming is a common issue with aggregate
(https://stackoverflow.com/questions/15309205/name-columns-within-aggregate-in-r)