aggregate-methods | R Documentation |

Aggregate a `"timeSeries"`

object over general periods.

```
## S4 method for signature 'timeSeries'
aggregate(x, by, FUN, ...)
```

`x` |
an object of class |

`by` |
a sequence of |

`FUN` |
the function to be applied. |

`...` |
arguments passed to other methods. |

`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`

.

an object of class `"timeSeries"`

`apply`

,
`align`

```
## 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)
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.