| aggregate-methods {timeSeries} | R Documentation |
Aggregate time series
Description
Aggregate a "timeSeries" object over general periods.
Usage
## S4 method for signature 'timeSeries'
aggregate(x, by, FUN, ...)
Arguments
x |
an object of class |
by |
a sequence of |
FUN |
the function to be applied. |
... |
arguments passed to other methods. |
Details
aggregate aggregates x by applying FUN on the
values of the time series in each of the aggregation periods,
specified by argument by.
Argument by should be of the same class as
time(x). by is sorted and duplicated values are removed
from it. Each pair of consecutive values in by then determines
a period over which to apply the aggregation function FUN, see
findInterval.
Value
an object of class "timeSeries"
See Also
Examples
## Load Microsoft Data Set -
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))
X <- aggregate(x, by, mean)
X
dayOfWeek(time(X))
isMonthly(X)
## Aggregate to Last Day of Quarter -
by <- unique(timeLastDayInQuarter(time(x)))
X <- aggregate(x, by, mean)
X
isQuarterly(X)
[Package timeSeries version 4032.109 Index]