Learn R Programming

funData (version 1.1)

extractObs: Extract observations of functional data

Description

This function extracts one or more observations and/or observations on a part of the domain from a funData, irregFunData or multiFunData object.

Usage

extractObs(object, obs = 1:nObs(object), argvals = getArgvals(object))

Arguments

object

An object of class funData, irregFunData or multiFunData.

obs

A numeric vector, giving the indices of the observations to extract (default: all obervations).

argvals

The part of the domain to be extracted (default: the whole domain object@argvals). Must be a list or a numeric vector (only for one-dimensional domains, see also the definition of , ).

Value

An object of class funData, irregFunData or multiFunData containing the desired observations.

Warning

The function is currently implemented only for functional data with up to three-dimensional domains.

Details

In case of an irregFunData object, some functions may not have observation points in the given part of the domain. In this case, the functions are removed from the extracted dataset and a warning is thrown.

See Also

, ,

Examples

Run this code
# Univariate - one-dimensional domain
object1 <- funData(argvals = 1:5, X = rbind(1:5, 6:10))
extractObs(object1, obs = 1)
extractObs(object1, argvals = 1:3)
extractObs(object1, argvals = list(1:3)) # the same as the statement before

# Univariate - two-dimensional domains
object2 <- funData(argvals = list(1:5, 1:6), X = array(1:60, dim = c(2, 5, 6)))
extractObs(object2, obs = 1)
extractObs(object2, argvals = list(1:3, c(2,4,6))) # argvals must be supplied as list

# Univariate - irregular
irregObject <- irregFunData(argvals = list(1:5, 2:4), X = list(2:6, 3:5))
extractObs(irregObject, obs = 2)
extractObs(irregObject, argvals = 1:3)
extractObs(irregObject, argvals = c(1,5)) # throws a warning, as second function has no observations

# Multivariate
multiObject <- multiFunData(object1, object2)
extractObs(multiObject, obs = 2)
extractObs(multiObject, argvals = list(1:3, list(1:3, c(2,4,6))))

Run the code above in your browser using DataLab