pcApply-methods: Apply a function to each season

pcApply-methodsR Documentation

Apply a function to each season

Description

Apply a function to each season.

Usage

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, ...)

Arguments

object

an object for which periodic mean makes sense.

nseasons

number of seasons.

FUN

a function, as for apply.

...

further arguments for FUN.

Details

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, ...).

Value

numeric or matrix for the methods described here, see section Details.

Methods

signature(object = "matrix")
signature(object = "numeric")
signature(object = "PeriodicMTS")
signature(object = "PeriodicTS")

Author(s)

Georgi N. Boshnakov

See Also

pcMean, apply

Examples

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)

GeoBosh/pcts documentation built on Dec. 8, 2023, 9:57 p.m.