Convert series to quarterly or annual.
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)
time series
a tframed object. (Only montly is currently working)
the function to use for aggregating.
Logical indicating if NA
should be removed from
the beginning and end of a series
a date which is used to determine the end of weeks.
the number of periods in a week.
additional arguments passed to aggregate
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.)
tfwindow
aggregate
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)
Run the code above in your browser using DataLab