split.xts: Divide into Groups by Time

View source: R/split.R

split.xtsR Documentation

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

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.

Value

A list of xts objects.

Note

aggregate.zoo() is more flexible, though not as fast for xts objects.

Author(s)

Jeffrey A. Ryan

See Also

endpoints(), split.zoo(), aggregate.zoo()

Examples


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


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


xts documentation built on June 22, 2024, 9:56 a.m.