Skip to content

Commit

Permalink
#32: Updated to select HEIGHT/LENGTH variable to create temporary HEI…
Browse files Browse the repository at this point in the history
…GHT variable. and modified the function call derive_params_growth_age to keep the derived parameters and corresponding input records only.
  • Loading branch information
Lina2689 committed May 15, 2024
1 parent 0d74ebc commit 6951da4
Showing 1 changed file with 10 additions and 24 deletions.
34 changes: 10 additions & 24 deletions inst/templates/ad_advs.R
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,9 @@ advs <- advs %>%
)

# Add Current HEIGHT Temporary variable (in cm)
## Calculate Current HEIGHT Temporary variable ----
## Calculate Current HEIGHT/LENGTH at each time point Temporary variable----
hgttmp <- advs %>%
filter(PARAMCD == "HEIGHT" & VSSTRESU == "cm") %>%
filter((PARAMCD == "HEIGHT" | PARAMCD == "LENGTH") & VSSTRESU == "cm") %>%
select(STUDYID, USUBJID, HGTTMP = AVAL, AVISIT)

advs <- advs %>%
Expand All @@ -259,8 +259,7 @@ advs <- advs %>%
## Calculate z-scores/percentiles
## Calculate Weight for AGE z-score and Percentile ----
## Note: PARAMN needs to be updated.
advs_wgt_age <- derive_params_growth_age(
advs,
advs <- advs %>% derive_params_growth_age(
sex = SEX,
age = AAGECUR,
age_unit = AAGECURU,
Expand All @@ -274,13 +273,11 @@ advs_wgt_age <- derive_params_growth_age(
PARAMCD = "WTAPCTL",
PARAM = "Weight-for-age percentile"
)
) %>%
filter(PARAMCD %in% c("WTASDS", "WTAPCTL"))
)

## Calculate BMI for AGE z-score and Percentile ----
## Note: PARAMN needs to be updated for z-score and percentile in final dataset.
advs_bmi_age <- derive_params_growth_age(
advs,
advs <- advs %>% derive_params_growth_age(
sex = SEX,
age = AAGECUR,
age_unit = AAGECURU,
Expand All @@ -294,13 +291,11 @@ advs_bmi_age <- derive_params_growth_age(
PARAMCD = "BMIPCTL",
PARAM = "BMI-for-age percentile"
)
) %>%
filter(PARAMCD %in% c("BMISDS", "BMIPCTL"))
)

## Calculate Head Circumference for AGE z-score and Percentile ----
## Note: PARAMN needs to be updated for z-score and percentile in final dataset.
advs_hdc_age <- derive_params_growth_age(
advs,
advs <- advs %>% derive_params_growth_age(
sex = SEX,
age = AAGECUR,
age_unit = AAGECURU,
Expand All @@ -314,15 +309,13 @@ advs_hdc_age <- derive_params_growth_age(
PARAMCD = "HDCPCTL",
PARAM = "HDC-for-age percentile"
)
) %>%
filter(PARAMCD %in% c("HDCSDS", "HDCPCTL"))
)

## Calculate for Height/Length ----
## derive_params_growth_height function not yet ready?
## It needs to be updated once the function is ready to use.
## from issue #34
# advs_wgt_height <- derive_params_growth_height(
# advs,
# advs <- advs %>% derive_params_growth_height(
# sex = SEX,
# age = AAGECUR,
# age_unit = AAGECURU,
Expand All @@ -338,14 +331,7 @@ advs_hdc_age <- derive_params_growth_age(
# PARAMCD = "WGTHPCTL",
# PARAM = "Weight-for-length/height Percentile"
# )
# ) %>%
# filter(PARAMCD %in% c("WGTHSDS", "WGTHPCTL"))

## Combine all derived parameters together
advs <- advs %>%
# z-score and percentile for HEIGHT and LENGTH to be added once the
# `derive_params_growth_height` function is ready
bind_rows(advs_wgt_age, advs_bmi_age, advs_hdc_age)
# )

## Add PARAM/PARAMN ----
advs <- advs %>%
Expand Down

0 comments on commit 6951da4

Please sign in to comment.