Learn R Programming

PAutilities (version 1.1.0)

bout_mvpa: Classify moderate-to-vigorous physical activity in bouts of a specific minimum length

Description

Classify moderate-to-vigorous physical activity in bouts of a specific minimum length

Usage

bout_mvpa(
  intensity,
  var_type = c("METs", "Intensity"),
  min_duration = 10,
  termination = 3,
  MoreArgs = list(breaks = c(-Inf, 1.51, 3, Inf), labels = c("SB", "LPA", "MVPA"),
    right = FALSE),
  ...,
  timestamps = NULL,
  output_var = c("is_MVPA", "bout_tracker")
)

Arguments

intensity

a vector of intensity classifications to be re-classified according to the bout definition

var_type

character scalar indicating whether the intensity variable is a numeric vector of metabolic equivalents, or a factor variable giving activity intensity classification

min_duration

numeric scalar: minimum duration of a qualifying bout, in minutes

termination

numeric scalar: consecutive minutes of non-MVPA required to terminate the bout

MoreArgs

required arguments passed to cut

...

optional arguments passed to cut for converting METs to intensity classification

timestamps

optional vector of POSIX-formatted timestamps. Must have same length as intensity

output_var

the output variable(s) to give

Examples

Run this code
data(ex_data, package = "PAutilities")
ex_data$DateTime <- as.POSIXct(ex_data$DateTime, "UTC")

# \donttest{
# Runs with a warning

bout_mvpa(ex_data$METs, "METs")

bout_mvpa(ex_data$METs, "METs", timestamps = ex_data$DateTime)
# }

# Recommended usage
lapply(split(ex_data, strftime(ex_data$DateTime, "%Y-%m-%d", "UTC")),
function(x) {
bout_mvpa(x$METs, "METs", timestamps = x$DateTime)
})

lapply(split(ex_data, strftime(ex_data$DateTime, "%Y-%m-%d", "UTC")),
function(x) {
bout_mvpa(x$METs,
"METs",
timestamps = x$DateTime,
output_var = "is_MVPA")
})

lapply(split(ex_data, strftime(ex_data$DateTime, "%Y-%m-%d", "UTC")),
function(x) {
bout_mvpa(x$METs,
"METs",
timestamps = x$DateTime,
output_var = "bout_tracker")
})

Run the code above in your browser using DataLab