View source: R/dt_modification.R
filtered_fold_dt | R Documentation |
If the dataset that is going to be folded contains several different time series instances of the same process, folding it could introduce false rows with data from different time series. Given an id variable that labels the different instances of a time series inside a dataset and a desired size, this function folds the dataset and avoids mixing data from different origins in the same instance.
filtered_fold_dt(dt, size, id_var, clear_id_var = TRUE)
dt |
data.table to be folded |
size |
the size of the data.table |
id_var |
the variable that labels each individual instance of the time series |
clear_id_var |
boolean that decides whether or not the id_var column is deleted |
the filtered data.table
dt <- dbnR::motor[201:2500]
dt[, n_sec := rep(seq(46), each = 50)] # I'll create secuences of 50 instances each
f_dt <- dbnR::fold_dt(dt, size = 2)
dim(f_dt)
f_dt <- dbnR::filtered_fold_dt(dt, size = 2, id_var = "n_sec")
dim(f_dt) # The filtered folded dt has a row less for each independent secuence
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.