Learn R Programming

stepmetrics (version 1.0.3)

get_cadence_bands: Calculate minutes and steps spent in cadence bands

Description

Splits a minute-based vector of cadence values (steps per minute) into predefined bands and reports both:

  • the number of minutes spent in each band

  • the number of steps accumulated in each band

Usage

get_cadence_bands(x, bands = c(0, 1, 20, 40, 60, 80, 100, 120, Inf))

Value

A list with three elements:

minutes

Named numeric vector with minutes spent in each band.

steps

Named numeric vector with steps accumulated in each band.

names

Character vector of variable names in the format "CAD_band_<lower>_<upper>_spm".

Arguments

x

Numeric vector of cadence values (steps per minute), where each element represents one minute of the day.

bands

Numeric vector of break points that define the cadence bands. Defaults to c(0, 1, 20, 40, 60, 80, 100, 120, Inf), which produces the bands 0, 1-19, 20-39, 40-59, 60-79, 80-99, 100-119, and 120+ spm.

Examples

Run this code
# Simulate 1 day of cadence values (1440 minutes)
set.seed(123)
cad <- sample(0:150, size = 1440, replace = TRUE)

out <- get_cadence_bands(cad)
out$minutes  # minutes in each band
out$steps    # steps in each band

Run the code above in your browser using DataLab