Learn R Programming

xts (version 0.14.1)

split.xts: Divide into Groups by Time

Description

Creates a list of xts objects split along time periods.

Usage

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

Value

A list of xts objects.

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 arguments passed to other methods.

Author

Jeffrey A. Ryan

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.

The inputs are passed to split.zoo() when f is not a character vector.

See Also

Examples

Run this code

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


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

Run the code above in your browser using DataLab