DataBackend for time series
DataBackendTimeSeries.Rd
DataBackend for data.table which serves as an efficient in-memory data base.
Super classes
mlr3::DataBackend
-> mlr3::DataBackendDataTable
-> DataBackendTimeSeries
Methods
Method new()
Creates a new instance of this R6 class.
Note that DataBackendDataTable
does not copy the input data, while as_data_backend()
calls data.table::copy()
.
as_data_backend()
also takes care about casting to a data.table()
and adds a primary key column if necessary.
Usage
DataBackendTimeSeries$new(data, primary_key, index)
Arguments
data
(
data.table::data.table()
)
The inputdata.table()
.primary_key
(
character(1)
|integer()
)
Name of the primary key column, or integer vector of row ids.index
(
character(1)
)
The time index of the time series.
Examples
data = tsbox::ts_dt(AirPassengers)
data[, id := 1:.N]
#> time value id
#> <Date> <num> <int>
#> 1: 1949-01-01 112 1
#> 2: 1949-02-01 118 2
#> 3: 1949-03-01 132 3
#> 4: 1949-04-01 129 4
#> 5: 1949-05-01 121 5
#> ---
#> 140: 1960-08-01 606 140
#> 141: 1960-09-01 508 141
#> 142: 1960-10-01 461 142
#> 143: 1960-11-01 390 143
#> 144: 1960-12-01 432 144
b = DataBackendTimeSeries$new(data = data, primary_key = "id", index = "time")