| reduce_frq | R Documentation |
Reduces the sampling frequency to a certain Hz value. If the desired frequency is smaller than the original frequency, the data remains unchanged.
reduce_frq(df, Hz = 200, measurement.col = NULL)
df |
Data frame or tibble in the below mentioned format. |
Hz |
Numeric value of desired frequency. Default |
measurement.col |
Character string. If |
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.
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 | ... |
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.