% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/subset.R
\name{extractObs}
\alias{extractObs}
\alias{subset,funData-method}
\alias{subset,multiFunData-method}
\alias{subset,irregFunData-method}
\alias{[,funData,ANY,missing,missing-method}
\alias{[,multiFunData,ANY,missing,missing-method}
\alias{[,irregFunData,ANY,missing,missing-method}
\title{Extract observations of functional data}
\usage{
extractObs(
  object,
  obs = seq_len(nObs(object)),
  argvals = funData::argvals(object)
)

\S4method{subset}{funData}(x, obs = seq_len(nObs(x)), argvals = funData::argvals(x))

\S4method{subset}{multiFunData}(x, obs = seq_len(nObs(x)), argvals = funData::argvals(x))

\S4method{subset}{irregFunData}(x, obs = seq_len(nObs(x)), argvals = funData::argvals(x))

\S4method{[}{funData,ANY,missing,missing}(x, i, j, ..., drop = TRUE)

\S4method{[}{multiFunData,ANY,missing,missing}(x, i, j, ..., drop = TRUE)

\S4method{[}{irregFunData,ANY,missing,missing}(x, i = seq_len(nObs(x)), j, ..., drop = TRUE)
}
\arguments{
\item{object}{An object of class \code{funData}, \code{irregFunData} or
\code{multiFunData}.}

\item{obs}{A numeric vector, giving the indices of the observations to
extract (default: all observations).}

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

\item{x}{An object of class \code{funData}, \code{irregFunData} or
\code{multiFunData} (for \code{subset}).}

\item{i}{A numeric vector, giving the indices of the observations to
extract when using \code{x[i]}. Defaults to all observations.}

\item{j, drop}{not used}

\item{...}{Used to pass further arguments to \code{extractObs}. Here
only usable for \code{argvals}.}
}
\value{
An object of class \code{funData}, \code{irregFunData} or
  \code{multiFunData} containing the desired observations.
}
\description{
This function extracts one or more observations and/or observations on
a part of the domain from a \code{funData}, \code{irregFunData} or
\code{multiFunData} object.
}
\details{
In case of an \code{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
\code{object[1:3]} is equivalent to \code{extractObs(object, obs =
1:3)}. This works only if the domain remains unchanged.
}
\section{Functions}{
\itemize{
\item \code{x[i}: 

}}
\section{Warning}{
 The function is currently implemented only for
  functional data with up to three-dimensional domains.
}

\section{Alias}{
 The function \code{subset} is an alias for
  \code{extractObs}.
}

\examples{
# 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]
}
\seealso{
\code{\linkS4class{funData}},
  \code{\linkS4class{irregFunData}}, \code{\linkS4class{multiFunData}}
}
