Skip to contents

This function determines a respondent's cardiovascular disease (CVD) personal history based on the presence or absence of specific conditions related to heart disease, heart attack, and stroke.

Usage

determine_CVD_personal_history(CCC_61, CCC_63, CCC_81)

Arguments

CCC_61

integer An integer representing the respondent's personal history of heart disease. 1 for "Yes" if the person has heart disease, 2 for "No" if the person does not have heart disease.

CCC_63

integer An integer representing the respondent's personal history of heart attack. 1 for "Yes" if the person had a heart attack, 2 for "No" if the person did not have a heart attack.

CCC_81

integer An integer representing the respondent's personal history of stroke. 1 for "Yes" if the person had a stroke, 2 for "No" if the person did not have a stroke.

Value

integer The CVD personal history: - 1: "Yes" if the person had heart disease, heart attack, or stroke. - 2: "No" if the person had neither of the conditions. - haven::tagged_na("a"): Not applicable - haven::tagged_na("b"): Missing

Details

This function synthesizes self-reported data on major cardiovascular events (heart disease, heart attack, stroke) into a single binary indicator.

     **Missing Data Codes:**
     - For all input variables:
       - `6`: Valid skip. Handled as `haven::tagged_na("a")`.
       - `7-9`: Don't know, refusal, or not stated. Handled as `haven::tagged_na("b")`.

Examples

# Scalar usage: Single respondent
# Determine CVD personal history for a person with heart disease (CCC_61 = 1).
determine_CVD_personal_history(CCC_61 = 1, CCC_63 = 2, CCC_81 = 2)
#> [1] 1
# Output: 1

# Example: Respondent has non-response values for all inputs.
result <- determine_CVD_personal_history(CCC_61 = 8, CCC_63 = 8, CCC_81 = 8)
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
determine_CVD_personal_history(CCC_61 = c(1, 2, 2), CCC_63 = c(2, 1, 2), CCC_81 = c(2, 2, 1))
#> [1] 1 1 1
# Returns: c(1, 1, 1)