This function categorizes individuals' weekly physical activity levels based on a threshold value.
Arguments
- minperweek
numeric A numeric representing an individual's minutes of moderate-to-vigorous physical activity (MVPA) per week.
Value
integer A categorical indicating the physical activity category:
1: Meets or exceeds the recommended 150 minutes of MVPA per week (minperweek >= 150)
2: Below the recommended 150 minutes of MVPA per week (minperweek < 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_minperweek(180)
#> [1] 1
# Output: 1
# Example 2: Categorize 120 minutes of MVPA per week as below the recommendation
categorize_minperweek(120)
#> [1] 2
# Output: 2
# Multiple respondents
categorize_minperweek(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_minperweek(min_per_week))