Skip to contents

This function performs either a bin- or a rolling-average on the interpolated data. You must specify the type of the average before continuing.

Usage

perform_average(
  .data,
  type = c("bin", "rolling", "ensemble"),
  bins = 30,
  bin_method = c("ceiling", "round", "floor"),
  rolling_window = 30
)

Arguments

.data

The second-by-second data retrieved from interpolate().

type

The type of the average to perform. Either bin, rolling, or ensemble.

bins

If bin-average is chosen, here you can specify the size of the bin-average, in seconds. Default to 30-s bin-average.

bin_method

Method for determining bin boundaries when type = "bin". One of "ceiling" (default), "round", or "floor". "ceiling" is recommended as it ensures no data points are excluded from the analysis by always rounding up to the next bin boundary.

rolling_window

If rolling-average is chosen, here you can specify the rolling-average window, in seconds. Default to 30-s rolling-average.

Value

a tibble

Details

Ensemble average is used in VO2 kinetics analysis, where a series of transitions from baseline to the moderate/heavy/severe intensity-domain is ensembled averaged into a single 'bout' for further data processing.

When using bin averaging, the bin_method parameter controls how time points are assigned to bins:

  • "ceiling": Rounds up to the next bin boundary (recommended)

  • "round": Rounds to the nearest bin boundary

  • "floor": Rounds down to the previous bin boundary

Examples

if (FALSE) { # \dontrun{
## get file path from example data
path_example <- system.file("example_cosmed.xlsx", package = "whippr")

## read data
df <- read_data(path = path_example, metabolic_cart = "cosmed")

## interpolate and perform 30-s bin-average
df %>%
 interpolate() %>%
 perform_average(type = "bin", bins = 30)

## interpolate and perform 30-s rolling-average
df %>%
 interpolate() %>%
 perform_average(type = "rolling", rolling_window = 30)
} # }