View source: R/rescale_mnirs.R
| rescale_mnirs | R Documentation |
Expand or reduce the range (min and max values) of data channels to a new
amplitude/dynamic range, e.g. re-scale the range of NIRS data to c(0, 100).
rescale_mnirs(
data,
nirs_channels = list(),
range,
verbose = TRUE
)
data |
A data frame of class "mnirs" containing time series data and metadata. |
nirs_channels |
A
|
range |
A numeric vector in the form |
verbose |
Logical. Default is |
nirs_channels = list() can be used to group data channels (column names)
to preserve absolute or relative scaling.
Channels grouped together in a vector (e.g. list(c("A", "B"))) will be
re-scaled to a common range, and the relative scaling within that group
will be preserved.
Channels in separate list vectors (e.g. list("A", "B")) will be
re-scaled independently, and relative scaling between groups will be lost.
A single vector of channel names (e.g. c("A", "B")) will group
channels together.
Channels (columns) in data not explicitly defined in nirs_channels
will be passed through untouched to the output data frame.
nirs_channels can be retrieved automatically from data of class
"mnirs" which has been processed with {mnirs}, if not defined
explicitly. This will default to returning all nirs_channels grouped
together, and should be defined explicitly for other grouping arrangements.
A tibble of class "mnirs" with metadata
available with attributes().
## read example data
data <- read_mnirs(
file_path = example_mnirs("moxy_ramp"),
nirs_channels = c(smo2_left = "SmO2 Live",
smo2_right = "SmO2 Live(2)"),
time_channel = c(time = "hh:mm:ss"),
verbose = FALSE
) |>
rescale_mnirs( ## un-grouped nirs channels to rescale separately
nirs_channels = list(smo2_left, smo2_right),
range = c(0, 100) ## rescale to a 0-100% functional exercise range
)
data
if (requireNamespace("ggplot2", quietly = TRUE)) {
plot(data, time_labels = TRUE) +
ggplot2::geom_hline(yintercept = c(0, 100), linetype = "dotted")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.