reduce_frq {forceR}R Documentation

Reduce Sampling Frequency

Description

Reduces the sampling frequency to a certain Hz value. If the desired frequency is smaller than the original frequency, the data remains unchanged.

Usage

reduce_frq(df, Hz = 200, measurement.col = NULL)

Arguments

df

Data frame or tibble in the below mentioned format.

Hz

Numeric value of desired frequency. Default 200

measurement.col

Character string. If measurement.col is not defined, the whole input data frames will be treated as if it was just one single time series. This is okay for data frames like that indeed only contain one time series, but for data frames with multiple time series, a grouping column needs to be defined. Default: NULL

Details

The input data frame or tibble should have the following format:

t y
t.1 y.1
... ...
t.n y.n

or, if measurement.col is not NULL, then

t y measurement.col
t.1 y.1 ...
... ... ...
t.n y.n ...

Since, when not NULL, the measurement.col is called by its character string, the position of the column does not matter, except it must not be among the first two columns which are reserved for t and y.

All columns except the first two are removed. Values in t are expected to be in m.secs.

Value

Returns a tibble reduced to the desired frequency in the following format:

t y
t.1 y.1
... ...
t.n y.n

or, if measurement.col is not NULL, then

t y measurement.col
t.1 y.1 ...
... ... ...
t.n y.n ...

Examples

require(dplyr)
# Using the forceR::df.all dataset that was
# simulated with forceR::simulate_bites()

# reduce sampling frequency to 200 Hz
df.all.200 <- reduce_frq(df = df.all,
                         Hz = 200,
                         measurement.col = "measurement")

plot(df.all.200 %>%
       filter(measurement == "m_02") %>%
       select(t, y),
     type = "l", col = "black")
lines(df.all.200 %>%
       filter(measurement == "m_01") %>%
       select(t, y),
     type = "l", col = "blue")

[Package forceR version 1.0.20 Index]