subset.ts

0th

Percentile

Subsetting a time series

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.

Keywords
ts
Usage
## S3 method for class 'ts':
subset(x, subset=NULL, month=NULL, quarter=NULL, season=NULL, ...)
Arguments
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.
Value

  • 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.

See Also

subset

Aliases
  • subset.ts
Examples
plot(subset(gas,month="November"))
subset(woolyrnq,quarter=3)
Documentation reproduced from package forecast, version 3.03, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.