Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

split

Divide into Groups by Time


Description

Creates a list of xts objects split along time periods.

Usage

## S3 method for class 'xts'
split(x, f = "months", drop=FALSE, k = 1, ...)

Arguments

x

an xts object

f

a 'character' vector describing the period to split by

drop

ignored by split.xts

k

number of periods to aggregate into each split. See Details.

...

further args to non-xts method

Details

A quick way to break up a large xts object by standard time periods; e.g. 'months', 'quarters', etc.

endpoints is used to find the start and end of each period (or k-periods). See that function for valid arguments.

If f is not a character vector, the NextMethod is called, which would in turn dispatch to the split.zoo method.

Value

A list of xts objects.

Note

aggregate.zoo would be more flexible, though not as fast for xts objects.

Author(s)

Jeffrey A. Ryan

See Also

Examples

data(sample_matrix)
x <- as.xts(sample_matrix)


split(x)
split(x, f="weeks")
split(x, f="weeks", k=4)

xts

eXtensible Time Series

v0.12.1
GPL (>= 2)
Authors
Jeffrey A. Ryan [aut, cph], Joshua M. Ulrich [cre, aut], Ross Bennett [ctb], Corwin Joy [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.