breakpoints {quantmod} | R Documentation |
Extract index values of a given zoo object, where the returned index is equal to the last date of each recurring period.
breakpoints(x, by = c(weekdays, weeks, months, quarters, years), ...)
x |
zoo object with index of class Date |
by |
period to be indexed from |
... |
currently unused |
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”.
A numeric vector which can be used to extract rows from the given data object.
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.
Jeffrey A. Ryan
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]