This function determines whether a given medication is a beta blocker. This function processes multiple inputs efficiently.
Value
numeric 1 if medication is a beta blocker, 0 otherwise. If inputs are invalid or out of bounds, the function returns a tagged NA.
Details
Identifies beta blockers based on ATC codes starting with "C07", excluding specific sub-codes.
Examples
# Scalar usage: Single respondent
is_beta_blocker("C07AA13", 3)
#> [1] 1
# Returns: 1
# Example: Respondent has non-response values for all inputs.
result <- is_beta_blocker("9999998", 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
is_beta_blocker(c("C07AA13", "C07AA07"), c(3, 4))
#> [1] 1 0
# Returns: c(1, 0)