# fd object
data("CanadianWeather")
temp <- CanadianWeather$dailyAv[, , "Temperature.C"]
basis <- create.bspline.basis(c(1, 365), nbasis = 8, norder = 4)
fd <- smooth.basis(1:365, temp, basis)$fd
# "Very Cold" = [-50:-10), "Cold" = [-10:0), ...
out <- convertToCfd(fd,
breaks = c(-50, -10, 0, 10, 20, 50),
labels = c("Very Cold", "Cold", "Fresh", "OK", "Hot"),
times = 1:365
)
# matrix
out2 <- convertToCfd(temp,
breaks = c(-50, -10, 0, 10, 20, 50),
labels = c("Very Cold", "Cold", "Fresh", "OK", "Hot"),
times = 1:365, byrow = FALSE
)
Run the code above in your browser using DataLab