aggregate function for objects of class
timeSeries and signalSeries.aggregateSeries(x, pos, FUN, moving=FALSE, together=FALSE, drop.empty=TRUE,
include.ends=FALSE, adj, offset, colnames, by, k.by=1,
week.align=NULL, holidays=timeDate(), align.by=TRUE,
incr=1, ...)by
argument if desired).mean, sum, or hloc.
If moving is FALSE,
FUN can also be a character string like "fastFFF",
to aggregate column-wise using the correspoFALSE to do standard aggregation,
or a positive integer N to perform a moving aggregation
(normally used for a moving average) over N samples.TRUE, passes all columns of x together into FUN;
If FALSE (the default), passes each column separately into FUN
for each aggregation block.TRUE (the default), drops aggregation blocks with
no positions to aggregate from the output.TRUE, includes the positions before the first
given aggregation block and after the last in the first/last blocks.
If FALSE (the default), does not include those positions in the output.adj towards the blocks ending position. The default is to use
the lower end of the block for the output position. 0.5 uses the
center of the aggregation blocadj, provide a constant offset to add
to the lower end of the aggregation block to get the output series
positions. For instance, in monthly aggregation, you might supply
an offset of 9 days so that the output positions pos is missing and by is supplied for aggregating
calendar-based time series, new positions are generated as a regular
time/date sequence using by, k.by, week.align,
and holidaysby. Ignored if
by is not a character string or if pos is given.NULL and by is "weeks",
you can supply a character
string (or a number, 0 to 6 with 0 being Sunday)
to specify a weekday to use for aggregation. The character string must
be sufficient to make a unique case-iby is not
a character string or pos is given.)TRUE (the default), adjustd the sequence so that each element is on a whole number
of the by * k.by units. For example, if the units are 2 months, make the sequence
be only on the first of January, March, and by, k.by, and so on,
(or possibly a subset if drop.empty is TRUE) and whose
rows are aggregated from x as specified in the arguments.
Aggregation takes place by separating x into blocks separated by the positions
(or overlapping blocks with a fixed number of samples if moving is
supplied), and then applying FUN to each column (or all columns
together if together is TRUE) and forming a new time series with
the positions and aggregated data.timeSeries , signalSeries ,
align, aggregatex <- timeSeries(data.frame(1:20,rnorm(20)), timeCalendar(d=1:20))
aggregate(x, FUN=mean, by="weeks")Run the code above in your browser using DataLab