
Last chance! 50% off unlimited learning
Sale ends in
This function extracts one or more observations and/or observations on
a part of the domain from a funData
, irregFunData
or
multiFunData
object.
extractObs(object, obs = seq_len(nObs(object)),
argvals = funData::argvals(object))# S4 method for funData
subset(x, obs = seq_len(nObs(x)),
argvals = funData::argvals(x))
# S4 method for multiFunData
subset(x, obs = seq_len(nObs(x)),
argvals = funData::argvals(x))
# S4 method for irregFunData
subset(x, obs = seq_len(nObs(x)),
argvals = funData::argvals(x))
# S4 method for funData,ANY,missing,missing
[(x, i, j, ..., drop = TRUE)
# S4 method for multiFunData,ANY,missing,missing
[(x, i, j, ..., drop = TRUE)
# S4 method for irregFunData,ANY,missing,missing
[(x, i = seq_len(nObs(x)), j,
..., drop = TRUE)
An object of class funData
, irregFunData
or
multiFunData
.
A numeric vector, giving the indices of the observations to extract (default: all observations).
An object of class funData
, irregFunData
or
multiFunData
(for subset
).
A numeric vector, giving the indices of the observations to
extract when using x[i]
. Defaults to all observations.
not used
Used to pass further arguments to extractObs
. Here
only usable for argvals
.
An object of class funData
, irregFunData
or
multiFunData
containing the desired observations.
x = funData,i = ANY,j = missing,drop = missing
:
The function is currently implemented only for functional data with up to three-dimensional domains.
The function subset
is an alias for
extractObs
.
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.
If only observations are to be extracted, the usual notation
object[1:3]
is equivalent to extractObs(object, obs =
1:3)
. This works only if the domain remains unchanged.
# NOT RUN {
# 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
# alias
subset(object1, argvals = 1:3)
# 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)
multiObject[2] # shorthand
extractObs(multiObject, argvals = list(1:3, list(1:3, c(2,4,6))))
### Shorthand via "[]"
object1[1]
object1[argvals = 1:3]
object2[1]
object2[argvals = list(1:3, c(2,4,6))]
irregObject[2]
irregObject[argvals = 1:3]
# }
Run the code above in your browser using DataLab