Learn R Programming

fda.usc (version 1.2.3)

Utilities: A wrapper for the split and unlist function for fdata object

Description

split.fdata divides the data in the fdata object x into the groups defined by f. Given a list structure x, unlist simplifies it to produce a fdata class object which contains all the atomic components which occur in x.

Usage

## S3 method for class 'fdata':
split(x,f,drop=FALSE,\dots)
## S3 method for class 'fdata':
unlist(x, recursive = TRUE, use.names = TRUE)

Arguments

x
an fdata object containing values to be divided into groups or an list of fdata objects containing values to be combine by rows in a to be flatten one fdata object
f
a factor in the sense that as.factor(f) defines the grouping, or a list of such factors in which case their interaction is used for the grouping.
drop
logical indicating if levels that do not occur should be dropped (if f is a factor or a list).
...
further potential arguments passed to methods.
recursive
logical. Should unlisting be applied to list components of x?
use.names
logical. Should names be preserved?

Value

  • The value returned from split is a list of fdata objects containing the values for the groups. The components of the list are named by the levels of f (after converting to a factor, or if already a factor and drop = TRUE, dropping unused levels). The value returned from unlist is a fdata object containing the fdata components of the list.

Examples

Run this code
fdataobj<-fdata(MontrealTemp)
fac<-factor(c(rep(1,len=17),rep(2,len=17)))
a1<-split.fdata(fdataobj,fac)
dim(a1[[1]]);dim(a1[[2]])
a2<-unlist.fdata(a1)
a2==fdataobj

Run the code above in your browser using DataLab