pcApply-methods | R Documentation |
Apply a function to each season.
pcApply(object, ...)
## S4 method for signature 'numeric'
pcApply(object, nseasons, FUN, ...)
## S4 method for signature 'matrix'
pcApply(object, nseasons, FUN, ...)
## S4 method for signature 'PeriodicTS'
pcApply(object, FUN, ...)
## S4 method for signature 'PeriodicMTS'
pcApply(object, FUN, ...)
object |
an object for which periodic mean makes sense. |
nseasons |
number of seasons. |
FUN |
a function, as for |
... |
further arguments for |
For univariate periodic time series, pcApply
applies FUN
to the data for each season. For multivariate periodic time series,
this is done for each variable.
The methods for "numeric"
and "matrix"
are equivalent to
those for "PeriodicTS"
and "PeriodicMTS"
,
respectively. The difference is that the latter two don't need
argument nseasons
and take the names of the seasons from
object
.
Argument "..."
is for further arguments to FUN
. In
particular, with many standard R functions argument na.rm =
TRUE
can be used to omit NA's, see the examples.
In the univariate case, when length(object)
is an integer
multiple of the number of seasons the periodic mean is equivalent to
apply(matrix(object, nrow = nseasons), 1, FUN, ...)
.
numeric or matrix for the methods described here, see section Details.
signature(object = "matrix")
signature(object = "numeric")
signature(object = "PeriodicMTS")
signature(object = "PeriodicTS")
Georgi N. Boshnakov
pcMean
,
apply
pcApply(pcts(presidents), mean, na.rm = TRUE)
pcMean(pcts(presidents), na.rm = TRUE) # same
pcApply(pcts(presidents), median, na.rm = TRUE)
pcApply(pcts(presidents), var, na.rm = TRUE)
pcApply(pcts(presidents), sd, na.rm = TRUE)
pcfr2to4 <- pcts(dataFranses1996)[2:4]
pcApply(pcfr2to4, median, na.rm = TRUE)
pcApply(pcfr2to4, sd, na.rm = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.