Validate Demographic Inputs for BP Functions (Internal)
Source:R/bp_family.R
dot-bp_validate_demo_input.RdInternal helper function to validate and standardize demographic inputs for blood pressure calculations. Checks age ranges, sex coding, and height z-scores against specified limits.
Arguments
- bp_type
Character;
"systolic"or"diastolic".- sex
Vector of sex codes in your data. Will be mapped to
"male"or"female"usingmale_codeandfemale_code. Values not matching these codes becomeNA.- male_code, female_code
Scalar values that identify the male and female codes in
sex(e.g.,1and2, or"M"and"F").- height_z
Numeric vector of height z-scores. Must already be z-transformed (e.g., US CDC, UK-WHO).
- height_limit
Positive numeric; z-scores with
|z| > height_limitare treated as invalid and set toNA. Default5.- age_years
Numeric vector of ages in years.
- ref
Reference:
"Fourth Report"(children/adolescents, 0-17) or"NICE/BHF"(adults, >17).- bp_value
Optional numeric vector of observed BP (mmHg); only used here to check that its length matches the other inputs.
- .quiet
Logical; suppress validation messages (default
FALSE).
Value
A list with normalized elements: bp_type, sex ("male" or "female" or NA),
age_years (invalid ages set to NA given ref), height_z (out-of-bound z set to NA),
ref, and bp_value (NULL if not supplied). It is an error if sex, age_years,
height_z and bp_value (when supplied) differ in length.
See also
Other BP functions:
.bp_message(),
.bp_resolve_limit(),
bp_assess(),
bp_category(),
bp_expected(),
bp_family,
bp_relative()