Categorical weekly moderate-to-vigorous physical activity (MVPA) indicator
Source:R/exercise.R
categorize_exercise.RdThis function categorizes individuals' weekly moderate-to-vigorous physical activity (MVPA) levels against the 150 minutes/week guideline.
Arguments
- exercise_min_week
numeric A numeric representing an individual's minutes of moderate-to-vigorous physical activity (MVPA) per week.
Value
integer A categorical indicating the MVPA category:
1: Meets or exceeds the recommended 150 minutes of MVPA per week (exercise_min_week >= 150)
2: Below the recommended 150 minutes of MVPA per week (exercise_min_week < 150)
haven::tagged_na("a"): Not applicablehaven::tagged_na("b"): Missing
Details
This function applies the national physical activity guideline of 150 minutes of moderate-to-vigorous physical activity (MVPA) per week.
Examples
# Scalar usage: Single respondent
# Example 1: Categorize 180 minutes of MVPA per week as meeting the recommendation
categorize_exercise(180)
#> [1] 1
# Output: 1
# Example 2: Categorize 120 minutes of MVPA per week as below the recommendation
categorize_exercise(120)
#> [1] 2
# Output: 2
# Multiple respondents
categorize_exercise(c(180, 120, 150))
#> [1] 1 2 1
# Returns: c(1, 2, 1)
# Database usage: Applied to survey datasets
# library(dplyr)
# dataset |>
# mutate(pa_category = categorize_exercise(min_per_week))