This function categorizes individuals' non-HDL cholesterol levels based on a threshold value.
Arguments
- nonHDL
numeric A numeric representing an individual's non-HDL cholesterol level.
Value
integer A categorical indicating the non-HDL cholesterol category:
1: High non-HDL cholesterol (nonHDL >= 4.3)
2: Normal non-HDL cholesterol (nonHDL < 4.3)
haven::tagged_na("a"): Not applicablehaven::tagged_na("b"): Missing
Details
This function categorizes non-HDL cholesterol levels into 'High' or 'Normal' based on a 4.3 mmol/L threshold.
Examples
# Scalar usage: Single respondent
# Example 1: Categorize a nonHDL value of 5.0 as high non-HDL cholesterol
categorize_nonHDL(5.0)
#> [1] 1
# Output: 1
# Example 2: Categorize a nonHDL value of 3.8 as normal non-HDL cholesterol
categorize_nonHDL(3.8)
#> [1] 2
# Output: 2
# Multiple respondents
categorize_nonHDL(c(5.0, 3.8, 4.3))
#> [1] 1 2 1
# Returns: c(1, 2, 1)
# Database usage: Applied to survey datasets
library(dplyr)
# dataset %>%
# mutate(non_hdl_category = categorize_nonHDL(non_hdl))