base-subsetting: Subsetting time series

TimeSeriesSubsettingsR Documentation

Subsetting time series


Objects from class "timeSeries" can be subsetted in different ways. Methods are defined for the subsetting operators "$", "[" and their assignment versions, as well as for some related functions from base R. A function to drop or extract outliers is also described here.


## S4 method for signature 'timeSeries'
head(x, n = 6, recordIDs = FALSE, ...)
## S4 method for signature 'timeSeries'
tail(x, n = 6, recordIDs = FALSE, ...)

outlier(x, sd = 5, complement = TRUE, ...)



an object of class timeSeries.


an integer specifying the number of lines to be returned. By default n=6.


a logical value. Should the recordIDs be returned together with the data matrix and time series positions?


a numeric value of standard deviations, e.g. 10 means that values larger or smaller than ten times the standard deviation will be removed from the series.


a logical flag. If TRUE, the default, return the series free of outliers. If FALSE, return the outliers series.


arguments passed to other methods.


The "timeSeries" methods for the subsetting operators "$", "[" and their assignment versions, as well as for the functions head and tail are meant to do what the user expects.

TODO: Further details are needed here, despite the above paragraph.

outlier drops the outliers if complement = TRUE and returns only them if complement = FALSE.

All functions described here return "timeSeries" objects.

See also window which extracts the sub-series between two datetimes.


All functions return an object of class "timeSeries".

See Also



## Create an Artificial 'timeSeries' Object - 
   setRmetricsOptions(myFinCenter = "GMT")
   charvec <- timeCalendar()
   data <- matrix(exp(cumsum(rnorm(12, sd = 0.1))))
   tS <- timeSeries(data, charvec, units = "tS")
## Subset Series by Counts "[" - 
   tS[1:3, ]
## Subset the Head of the Series - 
   head(tS, 6)

timeSeries documentation built on Aug. 26, 2023, 5:08 p.m.