Learn R Programming

timeSeries (version 3010.97)

aggregate-methods: timeSeries Class, Functions and Methods

Description

Aggregates a 'timeSeries' Object.

Usage

## S3 method for class 'timeSeries':
aggregate(x, by, FUN, \dots)

Arguments

by
[aggregate] - sequence of timeDate objects denoting the aggregation period.
FUN
the function to be applied.
x
an object of class timeSeries.
...
arguments passed to other methods.

Value

  • returns an aggregated S4 object of class timeSeries.

Examples

Run this code
## Load Microsoft Data Set -
   data(MSFT)
   x <- MSFT

## Aggregate by Weeks - 
   by <- timeSequence(from = start(x),  to = end(x), by = "week")
   aggregate(x, by, mean)

## Aggregate to Last Friday of Month -
   by <- unique(timeLastNdayInMonth(time(x), 5))
   aggregate(x, by, mean)

## Aggregate to Last Day of Quarter -
   by <- unique(timeLastDayInQuarter(time(x)))
   aggregate(x, by, mean)

Run the code above in your browser using DataLab