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))