Learn R Programming

timeSeries (version 4041.111)

series-methods: Get and set the data component of a 'timeSeries'

Description

Get and set the data component of a 'timeSeries'.

Usage

series(x)
series(x) <- value

Arguments

x

a timeSeries object.

value

a vector, a data.frame or a matrix object of numeric data.

Details

series returns the @.Data slot of a timeSeries object in matrix form.

The assignment version of series replaces the values of the time series with value. The row and column names of value are used if not NULL, otherwise they are left as in x. The most natural use is when value has the same dimensions as as.matrix(x), but if that is not the case the result is almost as if value was converted to "timeSeries" directly.

Methods for zoo::coredata and its assignment counterpart are defined, as well. Users who wish to use them should ensure that zoo::coredata is visible (e.g., by calling library('zoo') or library('xts')) or employ the zoo:: prefix in the calls. These methods are equivalent to series and `series<-`, respectively.

See Also

timeSeries

Examples

Run this code
## A Dummy 'timeSeries' Object
   ts <- timeSeries()
   ts

## Get the Matrix Part - 
   mat <- series(ts)
   class(mat)
   mat

## Assign a New Univariate Series - 
   series(ts) <- rnorm(12)
   ts
   
## Assign a New Bivariate Series - 
   series(ts) <- matrix(rnorm(12), ncol = 2)
   ts

Run the code above in your browser using DataLab