aggregateSeries | R Documentation |
Aggregation and coursening of time series and signals.
This is the method for the 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, ...)
x |
the series object to be aggregated. |
pos |
the break positions for aggregation (can also be supplied in the |
FUN |
the function to use for aggregation. Often Possible choices for |
moving |
either |
together |
a logical value. if |
drop.empty |
a logical value. If |
include.ends |
a logical value. If |
adj |
if provided, adjusts the positions of the output series so that they lie a
fraction |
offset |
as an alternative to |
colnames |
new column names for the output series. The default is to use the same names as the input series if the output series has the same width. |
by |
if
Alternatively, it can be one of the following character strings:
giving the time units of intervals between values in the sequence. |
k.by |
a non-zero integer giving the width of the interval between consecutive
values in the sequence in terms of the units given in |
week.align |
if not |
holidays |
holidays for business day sequences. (Ignored if |
align.by |
a logical value. If |
incr |
For moving aggregation, the moving window moves forward by this many steps in the time series, for each window. |
... |
Additional arguments to pass to FUN. |
returns a new time series whose positions are the adjusted passed-in positions or
positions generated from 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
, aggregate
x <- timeSeries(data.frame(1:20,rnorm(20)), timeCalendar(d=1:20))
aggregate(x, FUN=mean, by="weeks")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.