spiro_smooth | R Documentation |
Filter vectors and data frames with moving averages and digital filters.
Provides the data filtering for spiro_max
and
spiro_plot
.
spiro_smooth(data, smooth = 30, columns = NULL, quiet = FALSE)
data |
A data frame of the class |
smooth |
An integer or character string specifying the smoothing
strategy and parameters. Default is |
columns |
A character vector of the data columns that should be
filtered. By default the filtering applies to all data column of
|
quiet |
Whether warning message should be suppressed. Default is FALSE. |
Raw data from cardiopulmonary is usually noisy due to measurement error and biological breath-to-breath variability. When processing or visualizing the gas exchange data, it is often helpful to filter the raw data. This function provides different filtering methods (time average, breath average, digital filters).
Breath-based and digital filters will be applied on the raw breath-by-breath data. Time-based averages will be used on the interpolated data.
A data frame
smooth = 30
)A (centered) moving
average over a defined time span. The number can be given as an integer
or as a character (e.g. smooth = "30"
) and defines the length of
the calculation interval in seconds.
smooth = "15b"
)A (centered) moving average over a defined number of breaths. The integer before the letter 'b' defines the number of breaths for the calculation interval.
smooth = "0.04f3"
)A digital
Butterworth filter (with lag). The number before the letter 'f' defines
the low-pass cut-off frequency, the number after the letter 'f' gives the
order of the filter. See bw_filter
for more details.
smooth = "0.04fz3"
)A
digital forwards-backwards Butterworth filter (without lag). The number
before the letter 'f' defines the low-pass cut-off frequency, the number
after gives the order of the filter. See bw_filter
for more
details.
# Get example data
file <- spiro_example("zan_gxt")
d <- spiro(file)
out <- spiro_smooth(d, 30)
head(out)
# filter only the VO2 column with a zero-phase Butterworth filter
out2 <- spiro_smooth(d, "0.04fz3", columns = "VO2")
head(out2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.