Skip to contents

Various converters to turn tfb- or tfd-vectors into data.frames or matrices, or even an actual R function.

Usage

# S3 method for tf
as.data.frame(x, row.names = NULL, optional = FALSE, unnest = FALSE, ...)

# S3 method for tf
as.matrix(x, arg, interpolate = FALSE, ...)

# S3 method for tf
as.function(x, ...)

Arguments

x

a tf object

row.names

NULL or a character vector giving the row names for the data frame. Missing values are not allowed.

optional

not used

unnest

if TRUE, the function will return a data.frame with the evaluated functions.

...

additional arguments to be passed to or from methods.

arg

a vector of argument values / evaluation points for x. Defaults to tf_arg(x).

interpolate

should functions be evaluated (i.e., inter-/extrapolated) for values in arg for which no original data is available? Only relevant for the raw data class tfd, for which it defaults to FALSE. Basis-represented functional data tfb are always "interpolated".

Value

for as.data.frame.tf: if unnest is FALSE (default), a one-column data.frame with a tf-column containing x. if unnest is TRUE, a 3-column data frame with columns id for the (unique) names of x or a numeric identifier, arg and value, with each row containing one function evaluation at the original arg-values.

for as.matrix.tf: a matrix with one row per function and one column per arg.

for as.function.tf: an R function with argument arg that evaluates x on arg and returns the list of function values