View source: R/dt_modification.R
filter_same_cycle | R Documentation |
Given an id variable that labels the different instances of a time series inside a dataset, discard the rows that have values from more than 1 id.
filter_same_cycle(f_dt, size, id_var)
f_dt |
folded data.table |
size |
the size of the data.table |
id_var |
the variable that labels each individual instance of the time series |
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)
f_dt[50, .SD, .SDcols = c("n_sec_t_0", "n_sec_t_1")]
f_dt <- dbnR::filter_same_cycle(f_dt, size = 2, id_var = "n_sec")
f_dt[50, .SD, .SDcols = c("n_sec_t_0", "n_sec_t_1")]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.