as.quarterly: Aggregate Time Series

Description Usage Arguments Details Value See Also Examples

View source: R/utils.R

Description

Convert series to quarterly or annual.

Usage

1
2
3
    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 NA should be removed from the beginning and end of a series

foldFrom

a date which is used to determine the end of weeks.

periodicity

the number of periods in a week.

...

additional arguments passed to aggregate

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

tfwindow aggregate

Examples

1
2
3
4
5
6
7
8
9
  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)

tframePlus documentation built on May 19, 2017, 7:52 p.m.

Search within the tframePlus package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs in the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.