Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #2415 replaced hard coding of expr(USUBJID, STUDYID) or expr(USUBJID) with … #2452

Closed
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
941fa3a
replaced hard coding of expr(USUBJID, STUDYID) or expr(USUBJID) with …
ProfessorP-beep May 30, 2024
b0f3e0c
merged with changes from origin main
ProfessorP-beep May 30, 2024
fd5a292
merged with changes from origin main
ProfessorP-beep May 30, 2024
cb3363e
replaced expr(STUDYID, USUBJID) and expr(USUBJID) with !!!get_admiral…
ProfessorP-beep May 30, 2024
66a98fb
Merge branch 'main' into 2415-general-issue-make-subject-keys-flexibl…
ProfessorP-beep May 30, 2024
84794a1
ran styler::style_file("inst/templates/ad_adex.R") to address Code St…
ProfessorP-beep May 30, 2024
55f8b81
Merge branch '2415-general-issue-make-subject-keys-flexible-in-all-fu…
ProfessorP-beep May 30, 2024
2157bba
change instances of by = get_admiral_option(...) to by_vars =. Also r…
ProfessorP-beep May 31, 2024
e2638ed
Updated News.md
ProfessorP-beep May 31, 2024
80b9cf2
fixed syntax and remoced expr() from around get_admiral_options(...).…
ProfessorP-beep May 31, 2024
3628b0b
styler function ran on templates wasnt in last push
ProfessorP-beep May 31, 2024
b56823f
Missed some get_admiral_option syntax changes that werentt included i…
ProfessorP-beep May 31, 2024
61fd719
Addressed additional get_admiral_option(...) syntax issues
ProfessorP-beep May 31, 2024
7f00946
Fixed errors due to missing parentheses in ad_adex, ad_admh, and adpp…
ProfessorP-beep Jun 1, 2024
f51d7be
ran styler::style_file(c("inst/templates/ad_adex.R", "inst/templates/…
ProfessorP-beep Jun 1, 2024
5e20b1b
Added STUDYID to vignettes so that get_admiral_option("subject_keys")…
ProfessorP-beep Jun 4, 2024
d0d9aa1
ran styler_file() on changed vignettes in this commit
ProfessorP-beep Jun 4, 2024
badf8c9
ran styler_file() on changed vignettes in this commit. Reverted get_a…
ProfessorP-beep Jun 4, 2024
27dc85d
made changes to !!!adsl_vars to remove exclamations and bring it outs…
ProfessorP-beep Jun 4, 2024
8573bdc
addressed additional instances where get_admiral_options should be us…
ProfessorP-beep Jun 6, 2024
39de758
Merge branch 'main' into 2415-general-issue-make-subject-keys-flexibl…
ProfessorP-beep Jun 6, 2024
e379b8f
updated wordlist with spellcheck package
ProfessorP-beep Jun 6, 2024
d679577
resolving merge to update code
ProfessorP-beep Jun 6, 2024
6932070
additional USUBJID and STUDYID fixes
ProfessorP-beep Jun 6, 2024
bd1378f
received some errors in devtools::check() that I investigated then re…
ProfessorP-beep Jun 6, 2024
5b975ff
addressed missed replacements in inst/templates scripts
ProfessorP-beep Jun 6, 2024
50c2dd7
Ran spellcheck, lintr, and devtools to address pull request errors.
ProfessorP-beep Jun 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- New `country_code_lookup()` metadata added to decode countries based on [ISO 3166 codes](https://www.iso.org/iso-3166-country-codes.html). (#2388)

## Updates of Existing Functions
- Replaced hard coding of `expr(USUBJID, STUDYID)` and `expr(USUBJID)` with `get_admiral_option("subject_keys")` so the argument is flexible and can be changed from the default by the user. (#2415)

- Templates for ADPC, ADPPK and ADPP are updated to handle urine records. (#2392)

Expand Down
3 changes: 2 additions & 1 deletion R/duplicates.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ extract_duplicate_records <- function(dataset, by_vars) {
#' signal_duplicate_records(adsl, exprs(USUBJID), cnd_type = "message")
signal_duplicate_records <- function(dataset,
by_vars,
msg = "Dataset contains duplicate records with respect to {.var {replace_values_by_names(by_vars)}}", # nolint
msg = "Dataset contains duplicate records with respect to
{.var {replace_values_by_names(by_vars)}}", # nolint
cnd_type = "error") {
assert_expr_list(by_vars)
assert_data_frame(dataset, required_vars = extract_vars(by_vars), check_is_grouped = FALSE)
Expand Down
8 changes: 4 additions & 4 deletions inst/templates/ad_adae.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ adae <- ae %>%
derive_vars_merged(
dataset_add = adsl,
new_vars = adsl_vars,
by = exprs(STUDYID, USUBJID)
by_vars = get_admiral_option("subject_keys")
) %>%
## Derive analysis start time ----
derive_vars_dtm(
Expand Down Expand Up @@ -88,7 +88,7 @@ adae <- adae %>%
## Derive last dose date/time ----
derive_vars_joined(
dataset_add = ex_ext,
by_vars = exprs(STUDYID, USUBJID),
by_vars = get_admiral_option("subject_keys"),
new_vars = exprs(LDOSEDTM = EXSTDTM),
join_vars = exprs(EXSTDTM),
join_type = "all",
Expand Down Expand Up @@ -116,7 +116,7 @@ adae <- adae %>%
restrict_derivation(
derivation = derive_var_extreme_flag,
args = params(
by_vars = exprs(USUBJID),
by_vars = get_admiral_option("subject_keys"),
order = exprs(desc(ASEVN), ASTDTM, AESEQ),
new_var = AOCCIFL,
mode = "first"
Expand All @@ -128,7 +128,7 @@ adae <- adae %>%
adae <- adae %>%
derive_vars_merged(
dataset_add = select(adsl, !!!negate_vars(adsl_vars)),
by_vars = exprs(STUDYID, USUBJID)
by_vars = get_admiral_option("subject_keys")
)


Expand Down
6 changes: 3 additions & 3 deletions inst/templates/ad_adcm.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ adcm <- cm %>%
derive_vars_merged(
dataset_add = adsl,
new_vars = adsl_vars,
by = exprs(STUDYID, USUBJID)
by_vars = get_admiral_option("subject_keys")
) %>%
## Derive analysis start time ----
derive_vars_dtm(
Expand Down Expand Up @@ -97,7 +97,7 @@ adcm <- adcm %>%
derivation = derive_var_extreme_flag,
args = params(
new_var = AOCCPFL,
by_vars = exprs(USUBJID, CMDECOD),
by_vars = c(get_admiral_option("subject_keys"), exprs(CMDECOD)),
order = exprs(ASTDTM, CMSEQ),
mode = "first"
),
Expand Down Expand Up @@ -132,7 +132,7 @@ adcm <- adcm %>%
adcm <- adcm %>%
derive_vars_merged(
dataset_add = select(adsl, !!!negate_vars(adsl_vars)),
by_vars = exprs(STUDYID, USUBJID)
by_vars = get_admiral_option("subject_keys")
)


Expand Down
26 changes: 13 additions & 13 deletions inst/templates/ad_adeg.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ adeg <- eg %>%
derive_vars_merged(
dataset_add = adsl,
new_vars = adsl_vars,
by_vars = exprs(STUDYID, USUBJID)
by_vars = get_admiral_option("subject_keys")
) %>%
## Calculate ADTM, ADY ----
derive_vars_dtm(
Expand Down Expand Up @@ -137,15 +137,15 @@ adeg <- adeg %>%

# Derive RRR
derive_param_rr(
by_vars = exprs(STUDYID, USUBJID, !!!adsl_vars, VISIT, VISITNUM, EGTPT, EGTPTNUM, ADTM, ADY),
by_vars = c(get_admiral_option("subject_keys"), exprs(!!!adsl_vars, VISIT, VISITNUM, EGTPT, EGTPTNUM, ADTM, ADY)),
set_values_to = exprs(PARAMCD = "RRR"),
hr_code = "HR",
get_unit_expr = tolower(EGSTRESU),
filter = EGSTAT != "NOT DONE" | is.na(EGSTAT)
) %>%
# Derive QTCBR
derive_param_qtc(
by_vars = exprs(STUDYID, USUBJID, !!!adsl_vars, VISIT, VISITNUM, EGTPT, EGTPTNUM, ADTM, ADY),
by_vars = c(get_admiral_option("subject_keys"), exprs(!!!adsl_vars, VISIT, VISITNUM, EGTPT, EGTPTNUM, ADTM, ADY)),
method = "Bazett",
set_values_to = exprs(PARAMCD = "QTCBR"),
qt_code = "QT",
Expand All @@ -155,7 +155,7 @@ adeg <- adeg %>%
) %>%
# Derive QTCFR
derive_param_qtc(
by_vars = exprs(STUDYID, USUBJID, !!!adsl_vars, VISIT, VISITNUM, EGTPT, EGTPTNUM, ADTM, ADY),
by_vars = c(get_admiral_option("subject_keys"), exprs(!!!adsl_vars, VISIT, VISITNUM, EGTPT, EGTPTNUM, ADTM, ADY)),
method = "Fridericia",
set_values_to = exprs(PARAMCD = "QTCFR"),
qt_code = "QT",
Expand All @@ -165,7 +165,7 @@ adeg <- adeg %>%
) %>%
# Derive QTLCR
derive_param_qtc(
by_vars = exprs(STUDYID, USUBJID, !!!adsl_vars, VISIT, VISITNUM, EGTPT, EGTPTNUM, ADTM, ADY),
by_vars = c(get_admiral_option("subject_keys"), exprs(!!!adsl_vars, VISIT, VISITNUM, EGTPT, EGTPTNUM, ADTM, ADY)),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
by_vars = c(get_admiral_option("subject_keys"), exprs(!!!adsl_vars, VISIT, VISITNUM, EGTPT, EGTPTNUM, ADTM, ADY)),
by_vars = c(get_admiral_option("subject_keys"), adsl_vars, exprs(VISIT, VISITNUM, EGTPT, EGTPTNUM, ADTM, ADY)),

Other occurrences should be updated as well.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ProfessorP-beep did this one need an update?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops looks like I missed it. Can update in a bit.

method = "Sagie",
set_values_to = exprs(PARAMCD = "QTLCR"),
qt_code = "QT",
Expand Down Expand Up @@ -202,7 +202,7 @@ adeg <- adeg %>%
adeg <- adeg %>%
derive_summary_records(
dataset_add = adeg,
by_vars = exprs(STUDYID, USUBJID, !!!adsl_vars, PARAMCD, AVISITN, AVISIT, ADT),
by_vars = c(get_admiral_option("subject_keys"), exprs(!!!adsl_vars, PARAMCD, AVISITN, AVISIT, ADT)),
filter_add = dplyr::n() >= 2 & PARAMCD != "EGINTP",
set_values_to = exprs(
AVAL = mean(AVAL, na.rm = TRUE),
Expand Down Expand Up @@ -245,7 +245,7 @@ adeg <- adeg %>%
restrict_derivation(
derivation = derive_var_extreme_flag,
args = params(
by_vars = exprs(STUDYID, USUBJID, BASETYPE, PARAMCD),
by_vars = c(get_admiral_option("subject_keys"), exprs(BASETYPE, PARAMCD)),
order = exprs(ADT, VISITNUM, EGSEQ),
new_var = ABLFL,
mode = "last"
Expand All @@ -260,19 +260,19 @@ adeg <- adeg %>%
adeg <- adeg %>%
# Calculate BASE
derive_var_base(
by_vars = exprs(STUDYID, USUBJID, PARAMCD, BASETYPE),
by_vars = c(get_admiral_option("subject_keys"), exprs(PARAMCD, BASETYPE)),
source_var = AVAL,
new_var = BASE
) %>%
# Calculate BASEC
derive_var_base(
by_vars = exprs(STUDYID, USUBJID, PARAMCD, BASETYPE),
by_vars = c(get_admiral_option("subject_keys"), exprs(PARAMCD, BASETYPE)),
source_var = AVALC,
new_var = BASEC
) %>%
# Calculate BNRIND
derive_var_base(
by_vars = exprs(STUDYID, USUBJID, PARAMCD, BASETYPE),
by_vars = c(get_admiral_option("subject_keys"), exprs(PARAMCD, BASETYPE)),
source_var = ANRIND,
new_var = BNRIND
) %>%
Expand All @@ -286,7 +286,7 @@ adeg <- adeg %>%
restrict_derivation(
derivation = derive_var_extreme_flag,
args = params(
by_vars = exprs(USUBJID, PARAMCD, AVISIT, ATPT, DTYPE),
by_vars = c(get_admiral_option("subject_keys"), exprs(PARAMCD, AVISIT, ATPT, DTYPE)),
order = exprs(ADT, AVAL),
new_var = ANL01FL,
mode = "last"
Expand All @@ -306,7 +306,7 @@ adeg <- adeg %>%
# Calculate ASEQ
derive_var_obs_number(
new_var = ASEQ,
by_vars = exprs(STUDYID, USUBJID),
by_vars = get_admiral_option("subject_keys"),
order = exprs(PARAMCD, ADT, AVISITN, VISITNUM, ATPTN, DTYPE),
check_type = "error"
) %>%
Expand All @@ -329,7 +329,7 @@ adeg <- adeg %>%
adeg <- adeg %>%
derive_vars_merged(
dataset_add = select(adsl, !!!negate_vars(adsl_vars)),
by_vars = exprs(STUDYID, USUBJID)
by_vars = get_admiral_option("subject_keys")
)


Expand Down
18 changes: 9 additions & 9 deletions inst/templates/ad_adex.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ adex0 <- ex %>%
derive_vars_merged(
dataset_add = adsl,
new_vars = adsl_vars,
by_vars = exprs(STUDYID, USUBJID)
by_vars = get_admiral_option("subject_keys")
) %>%
## Calculate ASTDTM, AENDTM using `derive_vars_dtm()` ----
derive_vars_dtm(
Expand Down Expand Up @@ -159,7 +159,7 @@ adex <- adex %>%
)
),
dataset_add = adex,
by_vars = exprs(STUDYID, USUBJID, !!!adsl_vars)
by_vars = c(get_admiral_option("subject_keys"), adsl_vars)
) %>%
# W2-W24 exposure
call_derivation(
Expand Down Expand Up @@ -208,7 +208,7 @@ adex <- adex %>%
),
dataset_add = adex,
filter_add = VISIT %in% c("WEEK 2", "WEEK 24"),
by_vars = exprs(STUDYID, USUBJID, !!!adsl_vars)
by_vars = c(get_admiral_option("subject_keys"), adsl_vars)
) %>%
# Overall Dose intensity and W2-24 dose intensity
call_derivation(
Expand All @@ -225,8 +225,8 @@ adex <- adex %>%
tpadm_code = "PPDOSE"
)
),
by_vars = exprs(
STUDYID, USUBJID, !!!adsl_vars, PARCAT1, ASTDTM, ASTDT, AENDTM, AENDT
by_vars = c(
get_admiral_option("subject_keys"), exprs(!!!adsl_vars, PARCAT1, ASTDTM, ASTDT, AENDTM, AENDT)
)
) %>%
# Overall/W2-24 Average daily dose
Expand All @@ -248,8 +248,8 @@ adex <- adex %>%
)
)
),
by_vars = exprs(
STUDYID, USUBJID, !!!adsl_vars, PARCAT1, ASTDTM, ASTDT, AENDTM, AENDT
by_vars = c(
get_admiral_option("subject_keys"), exprs(!!!adsl_vars, PARCAT1, ASTDTM, ASTDT, AENDTM, AENDT)
)
)

Expand Down Expand Up @@ -306,7 +306,7 @@ adex <- adex %>%
# Calculate ASEQ
derive_var_obs_number(
new_var = ASEQ,
by_vars = exprs(STUDYID, USUBJID),
by_vars = get_admiral_option("subject_keys"),
order = exprs(PARCAT1, ASTDT, VISIT, VISITNUM, EXSEQ, PARAMN),
check_type = "error"
)
Expand All @@ -315,7 +315,7 @@ adex <- adex %>%
adex <- adex %>%
derive_vars_merged(
dataset_add = select(adsl, !!!negate_vars(adsl_vars)),
by_vars = exprs(STUDYID, USUBJID)
by_vars = get_admiral_option("subject_keys")
)

# Final Steps, Select final variables and Add labels
Expand Down
Loading
Loading