filter_same_cycle {dbnR} | R Documentation |
Filter the instances in a data.table with different ids in each row
Description
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.
Usage
filter_same_cycle(f_dt, size, id_var)
Arguments
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 |
Value
the filtered data.table
Examples
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")]
[Package dbnR version 0.7.9 Index]