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)
data.table to be folded
the size of the data.table
the variable that labels each individual instance of the time-series
boolean that decides whether or not the id_var column is deleted
the filtered dataset