base-subsetting: Subsetting time series

TimeSeriesSubsettingsR Documentation

Subsetting time series

Description

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.

Usage

## 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, ...)

Arguments

x

an object of class timeSeries.

n

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

recordIDs

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

sd

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.

complement

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

...

arguments passed to other methods.

Details

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.

Value

All functions return an object of class "timeSeries".

See Also

window

Examples

## Create an Artificial 'timeSeries' Object - 
   setRmetricsOptions(myFinCenter = "GMT")
   charvec <- timeCalendar()
   set.seed(4711)
   data <- matrix(exp(cumsum(rnorm(12, sd = 0.1))))
   tS <- timeSeries(data, charvec, units = "tS")
   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.