Convert data to categorical functional data
convertToCfd(
x,
breaks,
labels = NULL,
include.lowest = FALSE,
right = TRUE,
times = NULL,
idLabels = NULL,
nx = 200,
byrow = FALSE
)
matrix or fd object
either a numeric vector of two or more unique cut points or a single number (greater than or equal to 2) giving the number of intervals into which x is to be cut.
labels for the levels of the resulting category. By default, labels are constructed using "(a,b]" interval notation. If labels = FALSE, simple integer codes are returned instead of a factor.
logical, indicating if an ‘x[i]’ equal to the lowest (or highest, for right = FALSE) ‘breaks’ value should be included.
logical, indicating if the intervals should be closed on the right (and open on the left) or vice versa.
vector containing values at which fd
is to be evaluated
vector containing id labels. If NULL it use the names found in the matrix or fd object
Only if x
is a fd object. Number of points to evaluate fd
Only if x
is a matrix. If FALSE
, one column = one trajectory
a data.frame in the cfda format
Other format:
cut_data()
,
matrixToCfd()
,
remove_duplicated_states()
# 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)