apply.monthly

0th

Percentile

Apply Function over Calendar Periods

Apply a specified function to each distinct period in a given time series object.

Keywords
utilities
Usage
apply.daily(x, FUN, ...)
apply.weekly(x, FUN, ...)
apply.monthly(x, FUN, ...)
apply.quarterly(x, FUN, ...)
apply.yearly(x, FUN, ...)
Arguments
x

an time-series object coercible to xts

FUN

an R function

additional arguments to FUN

Details

Simple mechanism to apply a function to non-overlapping time periods, e.g. weekly, monthly, etc. Different from rolling functions in that this will subset the data based on the specified time period (implicit in the call), and return a vector of values for each period in the original data.

Essentially a wrapper to the xts functions endpoints and period.apply, mainly as a convenience.

Value

A vector of results produced by FUN, corresponding to the appropriate periods.

See Also

endpoints, period.apply, to.monthly

Aliases
  • apply.daily
  • apply.weekly
  • apply.monthly
  • apply.quarterly
  • apply.yearly
Examples
# NOT RUN {
xts.ts <- xts(rnorm(231),as.Date(13514:13744,origin="1970-01-01"))

start(xts.ts)
end(xts.ts)

apply.monthly(xts.ts,mean)
apply.monthly(xts.ts,function(x) var(x))
# }
Documentation reproduced from package xts, version 0.12-0, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.