subset.ts {forecast} | R Documentation |
The main purpose of this function is to extract the values of a specific season in each year. For example, to extract all values for the month of May from a time series.
## S3 method for class 'ts' subset(x, subset=NULL, month=NULL, quarter=NULL, season=NULL, ...)
x |
a univariate time series to be subsetted |
subset |
optional logical expression indicating elements to keep; missing values are taken as false. |
month |
Character list of months to retain. Partial matching on month names used. |
quarter |
Numeric list of quarters to retain. |
season |
Numeric list of seasons to retain. |
... |
Other arguments, unused. |
If one season per year is extracted, then a ts object is returned with frequency 1. Otherwise, a numeric vector is returned with no ts attributes.
Rob J Hyndman
plot(subset(gas,month="November")) subset(woolyrnq,quarter=3)