Learn R Programming

admiralpeds (version 0.3.0)

derive_interp_records: Derive interpolated rows for the CDC charts (>=2 yrs old)

Description

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

Usage

derive_interp_records(dataset, by_vars = NULL, parameter)

Value

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.

Arguments

dataset

Input metadataset

The variables AGE, AGEU, SEX, L, M, S are expected to be in the dataset

For BMI the additional variables P95 and Sigma are expected to be in the dataset

Note that AGE must be in days so that AGEU is equal to "DAYS"

Permitted values

a dataset, i.e., a data.frame or tibble

Default value

none

by_vars

Grouping variables

The variable from dataset which identifies the group of observations to interpolate separately.

Permitted values

list of variables created by exprs(), e.g., exprs(SEX)

Default value

NULL

parameter

CDC/WHO metadata parameter

Permitted values

a character scalar, i.e., a character vector of length one .

"WEIGHT", "HEIGHT" or "BMI" only - Must not be NULL e.g. parameter = "WEIGHT", parameter = "HEIGHT", or parameter = "BMI".

Default value

none

See Also

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

Examples

Run this code
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"
)

Run the code above in your browser using DataLab