apply.monthly {quantmod} | R Documentation |
Apply a specified function to each distinct period in a given time series object.
apply.weekly(x, FUN) apply.monthly(x, FUN) apply.quarterly(x, FUN) apply.yearly(x, FUN)
x |
an object of class zoo |
FUN |
an R function |
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 quantmod functions
breakpoints
and period.apply
, mainly as
a convenience.
A vector of results produced by FUN
, corresponding
to the appropriate periods.
Jeffrey A. Ryan
breakpoints
, period.apply
,
to.monthly
zoo.ts <- zoo(rnorm(231),as.Date(13514:13744,origin="1970-01-01")) start(zoo.ts) end(zoo.ts) apply.monthly(zoo.ts,sd) apply.monthly(zoo.ts,function(x) var(x))