as.quarterly {tframePlus} | R Documentation |
Aggregate Time Series
Description
Convert series to quarterly or annual.
Usage
as.quarterly(x, FUN=sum, na.rm=FALSE, ...)
as.annually(x, FUN=sum, na.rm=FALSE, ...)
as.weekly(x, FUN=sum, na.rm=FALSE, foldFrom=end(x), periodicity = 7)
Arguments
x |
a tframed object. (Only montly is currently working) |
FUN |
the function to use for aggregating. |
na.rm |
Logical indicating if |
foldFrom |
a date which is used to determine the end of weeks. |
periodicity |
the number of periods in a week. |
... |
additional arguments passed to |
Details
Functions as.quarterly
and as.annually
uses aggregate, but
shifts the data to match usual economic and
financial quarters or years (whereas aggregate simply groups together a number
of periods corresponding to the new frequency starting with the first
observation). These functions should give the same result as
aggregate if the data starts and ends on quarter (annual) boundaries.
If the data does not start and end on quarter (annual) boundaries
then NA
will be put in where
data is incomplete, and the quarter (year) removed if na.rm=TRUE
.
Monthly to annual gives the aggregate by converting first to quarterly, which is not exactly correct.
To weekly by periodicity
groupings from foldFrom
.
Partial weeks in the beginning or end are padded with NA
and
dropped if na.rm=FALSE
.
(as.weekly has been tested only with daily 7 day weeks.)
Value
time series
See Also
Examples
z <- ts(1:10, start = c(1999,2), frequency=4)
as.annually(z)
as.annually(z, na.rm=TRUE)
z <- ts(1:30, start = c(1999,2), frequency=12)
as.annually(z)
as.annually(z, na.rm=TRUE)
as.quarterly(z)
as.quarterly(z, na.rm=TRUE)