Convert data to categorical functional data

convertToCfd(
  x,
  breaks,
  labels = NULL,
  include.lowest = FALSE,
  right = TRUE,
  times = NULL,
  idLabels = NULL,
  nx = 200,
  byrow = FALSE
)

Arguments

x

matrix or fd object

breaks

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

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.

include.lowest

logical, indicating if an ‘x[i]’ equal to the lowest (or highest, for right = FALSE) ‘breaks’ value should be included.

right

logical, indicating if the intervals should be closed on the right (and open on the left) or vice versa.

times

vector containing values at which fd is to be evaluated

idLabels

vector containing id labels. If NULL it use the names found in the matrix or fd object

nx

Only if x is a fd object. Number of points to evaluate fd

byrow

Only if x is a matrix. If FALSE, one column = one trajectory

Value

a data.frame in the cfda format

See also

Examples

# 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)