| 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 |
measurement.col |
Character string. If |
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")