Learn R Programming

stepmetrics (version 1.0.3)

get_cadence_peaks: Calculate cadence peak metrics

Description

Cadence peaks represent the mean steps-per-minute (spm) achieved during the highest-activity minutes of a day. For example, the 30-minute cadence peak is the average cadence across the 30 highest cadence minutes of that day, regardless of whether they occur consecutively.

This function calculates cadence peaks for user-specified intervals and also reports how many of the minutes within each interval contain zero steps (useful for quality checks).

Usage

get_cadence_peaks(x, peaks = c(1, 30, 60))

Value

A list with two elements:

values

Numeric vector with cadence peak values (spm) followed by the corresponding counts of zero-minute values within each peak window.

names

Character vector of variable names corresponding to the `values`, in the format:

  • `"CAD_pk<peak>_spm"` for the cadence peak value

  • `"CAD_nZeroes_pk<peak>"` for the number of zero minutes

Arguments

x

Numeric vector of cadence values (steps per minute) for the day of interest. Each element should represent one minute.

peaks

Numeric vector of integers specifying which cadence peaks to compute. For example, `c(1, 30, 60)` (default) produces the 1-minute, 30-minute, and 60-minute cadence peaks.

Details

Cadence peaks are calculated by:

  1. Sorting all minute-level cadence values in descending order.

  2. Selecting the top *n* minutes, where *n* = peak length.

  3. Averaging those values to compute the cadence peak.

  4. Counting how many of those top *n* minutes contain zero steps.

See Also

[get_cadence_bands()]

Examples

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

# Calculate 1-min, 30-min, and 60-min cadence peaks
get_cadence_peaks(cad, peaks = c(1, 30, 60))

Run the code above in your browser using DataLab