breakpoints {quantmod}R Documentation

Locate Breakpoints by Date

Description

Extract index values of a given zoo object, where the returned index is equal to the last date of each recurring period.

Usage

breakpoints(x, by = c(weekdays, weeks, months, quarters, years),
            ...)

Arguments

x zoo object with index of class Date
by period to be indexed from
... currently unused

Details

Given a zoo object with the appropriate index type, breakpoints will return a numeric vector corresponding to the final rows in each period specified.

For example, by=years would return the index values matching the last observation in each calendar year. Similarly, by=weeks would match the last observations in any given week.

The final index returned corresponds to the last observation in the data object, as this may be useful for calculating “values to date”.

Value

A numeric vector which can be used to extract rows from the given data object.

Note

The last value in the returned vector most likely does not mark the end of the specified period, rather it marks the end of the data.

Author(s)

Jeffrey A. Ryan

Examples

zoo.data <- zoo(rnorm(31)+10,as.Date(13514:13744,origin="1970-01-01"))
breakpoints(zoo.data,by=weeks)

bp <- breakpoints(zoo.data,by=quarters)
zoo.data[bp]

[Package quantmod version 0.3-4 Index]