This function calculates the Waist-to-Height Ratio (WHtR) by dividing the waist circumference by the height of the respondent.
Value
numeric The WHtR. If inputs are invalid or out of bounds, the function returns a tagged NA.
Details
This function calculates the Waist-to-Height Ratio (WHtR), an indicator of central obesity.
**Missing Data Codes:**
- `HWM_11CM`:
- `999.96`: Valid skip. Handled as `haven::tagged_na("a")`.
- `999.97-999.99`: Don't know, refusal, or not stated. Handled as `haven::tagged_na("b")`.
- `HWM_14CX`:
- `999.6`: Valid skip. Handled as `haven::tagged_na("a")`.
- `999.7-999.9`: Don't know, refusal, or not stated. Handled as `haven::tagged_na("b")`.Examples
# Scalar usage: Single respondent
# Example 1: Calculate WHtR for a respondent with height = 170 cm and waist circumference = 85 cm.
calculate_WHR(HWM_11CM = 170, HWM_14CX = 85)
#> [1] 0.5
# Output: 0.5 (85/170)
# Example 2: Calculate WHtR for a respondent with missing height.
result <- calculate_WHR(HWM_11CM = 999.98, HWM_14CX = 85)
result # Shows: NA
#> [1] NA
haven::is_tagged_na(result, "b") # Shows: TRUE (confirms it's tagged NA(b))
#> [1] TRUE
format(result, tag = TRUE) # Shows: "NA(b)" (displays the tag)
#> [1] "NA"
# Multiple respondents
calculate_WHR(HWM_11CM = c(170, 180, 160), HWM_14CX = c(85, 90, 80))
#> [1] 0.5 0.5 0.5
# Returns: c(0.5, 0.5, 0.5)
# Database usage: Applied to survey datasets
library(dplyr)
# dataset %>%
# mutate(whtr = calculate_WHR(HWM_11CM, HWM_14CX))