filtered_fold_dt {dbnR}R Documentation

Fold a dataset avoiding overlapping of different time series

Description

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.

Usage

filtered_fold_dt(dt, size, id_var, clear_id_var = TRUE)

Arguments

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

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)
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

[Package dbnR version 0.7.8 Index]