reduce_freq {dbnR}R Documentation

Reduce the frequency of the time series data in a data.table

Description

In a time series dataset, there is a time difference between one row and the next one. This function reduces the number of rows from its current frequency to the desired one by averaging batches of rows. Instead of the frequency in Hz, the number of seconds between rows is asked (Hz = 1/s).

Usage

reduce_freq(dt, obj_freq, curr_freq, id_var = NULL)

Arguments

dt

the original data.table

obj_freq

the desired number of seconds between rows

curr_freq

the number of seconds between rows in the original dataset

id_var

optional variable that labels different time series in a dataset, to avoid averaging values from different processes

Value

the data.table with the desired frequency

Examples

# Let's assume that the dataset has a frequency of 4Hz, 0.25 seconds between rows
dt <- dbnR::motor
dim(dt)
# Let's change the frequency to 2Hz, 0.5 seconds between rows
dt <- reduce_freq(dt, obj_freq = 0.5, curr_freq = 0.2)
dim(dt)

[Package dbnR version 0.7.8 Index]