Skip to content

Commit

Permalink
(#23) Styled file
Browse files Browse the repository at this point in the history
  • Loading branch information
AndersAskeland committed Oct 5, 2024
1 parent d6e7bc2 commit d7ad784
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions inst/ad_advs.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ avalcat_lookup <- exprs(
"BMI", AVAL >= 30 & AVAL < 35, "Obesity class I", 4,
"BMI", AVAL >= 35 & AVAL < 40, "Obesity class II", 5,
"BMI", AVAL >= 40, "Obesity class III", 6,
"BMI", is.na(AVAL), NA_character_, NA_integer_)
"BMI", is.na(AVAL), NA_character_, NA_integer_
)

# Read in data ----
# See the "Read in Data" vignette section for more information:
Expand Down Expand Up @@ -107,7 +108,8 @@ advs <- advs |>
VISIT == "BASELINE" ~ 0,
str_detect(VISIT, "WEEK") ~ as.integer(str_extract(VISIT, "\\d+")),
TRUE ~ NA_integer_
))
)
)


# Derive results ----
Expand All @@ -129,14 +131,18 @@ advs <- advs |>
advs <- advs |>
filter(VSTESTCD != "BMI") |>
derive_param_bmi(
by_vars = exprs(STUDYID, USUBJID, TRTSDT, TRTEDT, TRT01P, TRT01A, VISIT,
VISITNUM, ADT, ADY, VSTPT, VSTPTNUM),
set_values_to = exprs(PARAMCD = "BMI",
DOMAIN = "VS"),
get_unit_expr = VSSTRESU,
filter = VSSTAT != "NOT DONE" | is.na(VSSTAT),
constant_by_vars = exprs(USUBJID)
)
by_vars = exprs(
STUDYID, USUBJID, TRTSDT, TRTEDT, TRT01P, TRT01A, VISIT,
VISITNUM, ADT, ADY, VSTPT, VSTPTNUM
),
set_values_to = exprs(
PARAMCD = "BMI",
DOMAIN = "VS"
),
get_unit_expr = VSSTRESU,
filter = VSSTAT != "NOT DONE" | is.na(VSSTAT),
constant_by_vars = exprs(USUBJID)
)


# Derive categorization variables ----
Expand Down Expand Up @@ -251,4 +257,3 @@ if (!file.exists(dir)) {
dir.create(dir, recursive = TRUE, showWarnings = FALSE)
}
save(advs, file = file.path(dir, "advs.rda"), compress = "bzip2")

0 comments on commit d7ad784

Please sign in to comment.