Learn R Programming

timeSeries (version 4030.106)

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.

coredata and its assignment counterpart are equivalent alternatives to series and its assignment part, 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