Get and set the data component of a 'timeSeries'
timeSeries-slotSeries.Rd
Get and set the data component of a 'timeSeries'.
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.
Examples
## A Dummy 'timeSeries' Object
ts <- timeSeries()
ts
#>
#> SS.1
#> [1,] NA
## Get the Matrix Part -
mat <- series(ts)
class(mat)
#> [1] "matrix" "array"
mat
#> SS.1
#> [1,] NA
## Assign a New Univariate Series -
series(ts) <- rnorm(12)
ts
#>
#> SS.1
#> [1,] -0.6937202
#> [2,] -1.4482049
#> [3,] 0.5747557
#> [4,] -1.0236557
#> [5,] -0.0151383
#> [6,] -0.9359486
#> [7,] 1.1022975
#> [8,] -0.4755931
#> [9,] -0.7094400
#> [10,] -0.5012581
#> [11,] -1.6290935
#> [12,] -1.1676193
## Assign a New Bivariate Series -
series(ts) <- matrix(rnorm(12), ncol = 2)
ts
#>
#> SS.1 SS.2
#> [1,] -2.1800396 -0.8553646
#> [2,] -1.3409932 -0.2806230
#> [3,] -0.2942939 -0.9943401
#> [4,] -0.4658975 -0.9685143
#> [5,] 1.4494963 -1.1073182
#> [6,] -1.0686427 -1.2519859