derive_interp_records {admiralpeds} | R Documentation |
Derive a linear interpolation of rows for the CDC charts (>=2 yrs old) by age in days for the following parameters: HEIGHT, WEIGHT and BMI
derive_interp_records(dataset, by_vars = NULL, parameter)
dataset |
Input metadataset The variables For BMI the additional variables Note that |
by_vars |
Grouping variables The variable from |
parameter |
CDC/WHO metadata parameter Permitted Values: |
The input dataset plus additional interpolated records: a record for each day from the minimum age to the maximum age.
If any variables in addition to the expected ones are in the input dataset, LOCF (Last Observation Carried Forward) is applied to populate them for the new records.
Metadata
cdc_bmiage
,
cdc_htage
,
cdc_wtage
,
who_bmi_for_age_boys
,
who_bmi_for_age_girls
,
who_hc_for_age_boys
,
who_hc_for_age_girls
,
who_lgth_ht_for_age_boys
,
who_lgth_ht_for_age_girls
,
who_wt_for_age_boys
,
who_wt_for_age_girls
,
who_wt_for_lgth_boys
,
who_wt_for_lgth_girls
library(dplyr, warn.conflicts = FALSE)
library(rlang, warn.conflicts = FALSE)
cdc_htage <- admiralpeds::cdc_htage %>%
mutate(
SEX = case_when(
SEX == 1 ~ "M",
SEX == 2 ~ "F",
TRUE ~ NA_character_
),
# Ensure first that Age unit is "DAYS"
AGE = round(AGE * 30.4375),
AGEU = "DAYS"
)
# Interpolate the AGE by SEX
derive_interp_records(
dataset = cdc_htage,
by_vars = exprs(SEX),
parameter = "HEIGHT"
)