-
Notifications
You must be signed in to change notification settings - Fork 63
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
Closes #2415 replaced hard coding of expr(USUBJID, STUDYID) or expr(USUBJID) with … #2452
Conversation
…!!!get_admiral_option("subject_keys") to allow for flexibility in using the function. There is an error in the bds_exposure.Rmd markdown on line 361, chunk 22 that needs to be fixed.
Looking nice @ProfessorP-beep! Can you just run styler on your code |
…_option("subject_keys") in .Rmd files and ran each file to check for errors.
…e-in-all-functions
…yle error in pull request check
…nctions' of https://github.com/pharmaverse/admiral into 2415-general-issue-make-subject-keys-flexible-in-all-functions Merged pull request with main branch update
I'm still getting the error with pkgdown::build_site(), but everything else, including running the .Rmd checks out. It's running again right now after merging an update. |
I will see if I can build site on my end |
I was able to build website - I will review PR. @manciniedoardo can you also help with review please. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments, thanks @ProfessorP-beep !
inst/templates/ad_adae.R
Outdated
@@ -40,7 +40,7 @@ adae <- ae %>% | |||
derive_vars_merged( | |||
dataset_add = adsl, | |||
new_vars = adsl_vars, | |||
by = exprs(STUDYID, USUBJID) | |||
by = exprs(!!!get_admiral_option("subject_keys")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be by_vars
not by
. Partial matching might save us here but better to use the right argument directly.
Also, I believe in this case you could do by_vars = get_admiral_option("subject_keys")
directly rather than quoting and unquoting by_vars = exprs(!!!get_admiral_option("subject_keys"))
(this is applicable in lots of other places as well.) You'd only need to use exprs
and unquoting when you want to use other by vars as well, for instance by_vars = exprs(!!!get_admiral_option("subject_keys"), AEDECOD)
- @bundfussr do you agree?
Maybe you could do a blanket find and replace for by_vars = exprs(!!!get_admiral_option("subject_keys"))
-> by_vars = get_admiral_option("subject_keys")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I believe in this case you could do
by_vars = get_admiral_option("subject_keys")
directly rather than quoting and unquotingby_vars = exprs(!!!get_admiral_option("subject_keys"))
(this is applicable in lots of other places as well.) You'd only need to useexprs
and unquoting when you want to use other by vars as well, for instanceby_vars = exprs(!!!get_admiral_option("subject_keys"), AEDECOD)
- @bundfussr do you agree?
I agree.
inst/templates/ad_adcm.R
Outdated
@@ -36,7 +36,7 @@ adcm <- cm %>% | |||
derive_vars_merged( | |||
dataset_add = adsl, | |||
new_vars = adsl_vars, | |||
by = exprs(STUDYID, USUBJID) | |||
by = exprs(!!!get_admiral_option("subject_keys")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, should use by_vars
not by
…emoved "!!!" from get_admiral_options as we do not neednto use unquoting where it is an argument
@ProfessorP-beep sorry, would it be possible to please update the occasions where we have |
@manciniedoardo Already done. I realized my mistake after that last push. New one coming as soon as the checks are done. |
… Also ran styler() on ad.adcm.rm ad_adae, and occds.Rmd
Sorry, hold off on reviewing on minute. Some of the changes weren't pushed through. |
…ad_adppk.R")) to fix code style error
and thanks @ProfessorP-beep for seeing this through!! This is how it works on the team :) We do PRs and I get a little huffy and puffy and ask funny questions - which usually are me being paranoid. |
Thanks @bms63 - all fair questions, but i guess these all would have been discussed when we first added this option. Now that we have it offered in the package, we just need to make sure it works :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few missed occurrences:
(base) bundfuss@rstudio:(templates)> grep USUBJID *.R
ad_adlbhy.R: select(STUDYID, USUBJID, TRT01A, PARAMCD, LBSEQ, ADT, AVISIT, ADY, AVAL, ANRHI, CRIT1, CRIT1FL)
ad_adlbhy.R: select(STUDYID, USUBJID, TRT01A) %>% # add AVISIT, ADT for by visit
ad_adlbhy.R: select(STUDYID, USUBJID, TRT01A, CRIT1FL, BILI_CRITFL) %>% # add AVISIT, ADT for by visit
ad_advs.R: # by_vars = exprs(STUDYID, USUBJID, PARAMCD, BASETYPE),
inst/templates/ad_adex.R
Outdated
@@ -159,7 +159,7 @@ adex <- adex %>% | |||
) | |||
), | |||
dataset_add = adex, | |||
by_vars = exprs(STUDYID, USUBJID, !!!adsl_vars) | |||
by_vars = c(get_admiral_option("subject_keys"), exprs(!!!adsl_vars)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by_vars = c(get_admiral_option("subject_keys"), exprs(!!!adsl_vars)) | |
by_vars = c(get_admiral_option("subject_keys"), adsl_vars) |
Other occurrences should be updated as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha, I'll take a look at these. I think I was getting some error messages when using this with select(), but I'll look again and post it here if it comes up.
inst/templates/ad_adeg.R
Outdated
@@ -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)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
@@ -245,7 +245,7 @@ advs <- derive_vars_merged_lookup( | |||
```{r, eval=TRUE, echo=FALSE} | |||
advs_param <- distinct(advs, USUBJID, PARAMCD, VSTESTCD) | |||
|
|||
dataset_vignette(advs_param, display_vars = exprs(USUBJID, VSTESTCD, PARAMCD)) | |||
dataset_vignette(advs_param, display_vars = exprs(!!get_admiral_option("subject_keys")[[2]], VSTESTCD, PARAMCD)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either we should update line 246 as well or we should not update this line.
vignettes/generic.Rmd
Outdated
@@ -219,7 +219,7 @@ advs <- tribble( | |||
derive_vars_merged( | |||
adsl, | |||
dataset_add = advs, | |||
by_vars = exprs(USUBJID), | |||
by_vars = exprs(!!get_admiral_option("subject_keys")[[2]]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks confusing to me. We don't have any rules or convention on the number of elements in "subject_keys" or which variable is placed where. You could have exprs(USUBJID, STUDYID)
, exprs(STUDYID, SITEID, SUBJID)
, or exprs(USUBJID)
. I.e., selecting a certain element is not a good idea because in general you don't know what you get.
I would either add STUDYID
to the data and use get_admiral_option("subject_keys")
instead of exprs(!!get_admiral_option("subject_keys")[[2]])
or just leave it as it is.
@bms63 , @rossfarrugia , what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add STUDYID
to the data and use get_admiral_option("subject_keys")
would be my preference. i don't like the [[2]]
option either - as risky for future robustness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is being used in derive_var_trtemfl()
as well. I flagged as concerning for me #2362 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ProfessorP-beep do you have time to make these final changes today?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, I should be able to get to it this afternoon / early evening.
No problem! I'm also learning a lot more so this is cool. I'm looking through the discussion now. |
… can be used instead of subsetting with []. Replaced instances of !!!adsl_vars with just adsl_vars. Found other instances of USUBJID, STUDYID and replaced with get_admiral_optios("subject_keys") where errors didnt occur from the change.
…dmiral_options to USUBJID, STUDYID inside of select() functions to see if thats why scripts couldnt be executed
…ide the exprs() argument when defining by_vars
inst/templates/ad_adlbhy.R
Outdated
@@ -43,7 +43,7 @@ adlb_annotated <- adlb %>% | |||
) | |||
) | |||
) %>% | |||
select(STUDYID, USUBJID, TRT01A, PARAMCD, LBSEQ, ADT, AVISIT, ADY, AVAL, ANRHI, CRIT1, CRIT1FL) | |||
select(USUBJID, STUDYID, TRT01A, PARAMCD, LBSEQ, ADT, AVISIT, ADY, AVAL, ANRHI, CRIT1, CRIT1FL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why was this one left behind with just the order of USUBJID and STUDYID swapped? noticed this by chance as was using this PR to prompt same changes in admiralonco. please double check any others
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as FYI should be select(!!!get_admiral_option("subject_keys"), TRT01A, ...etc)
@bundfussr @rossfarrugia @manciniedoardo - This update isn't critical to me for 1.1. Can we implement for 1.2 as it is actually quite large and seems to be opening lots of questions? |
Ok, let's leave until 1.2 to ensure we do this right and don't have to come back to it later. I still think it's an important update to make, and we can definitely still leverage all the work done by @ProfessorP-beep in this PR, but what we have now is not wrong per se, just a bit inconsistent. |
Hi @ProfessorP-beep, we can talk about this tomorrow, but going to pause on this PR until after we ship 1.1 release. This will be our first PR into 1.2! |
…ed, tested rmd and testthat files, but more test files should be addressed and tested where USUBJID and STUDYID are used.
Sounds good, I'm just gonna push the additional changes I've done since then. There is probably still some review to be done to make sure all cases are addressed. |
…e-in-all-functions
…verted the files back to their original script. There is a missing dependency import for "glue"
This Pull Request is stale because it has not been worked on in 15 days. |
This Pull Request is stale because it has not been worked on in 15 days. |
…!!!get_admiral_option("subject_keys") to allow for flexibility in using the function. There is an error in the bds_exposure.Rmd markdown on line 361, chunk 22 that needs to be fixed.
Thank you for your Pull Request! We have developed this task checklist from the Development Process Guide to help with the final steps of the process. Completing the below tasks helps to ensure our reviewers can maximize their time on your code as well as making sure the admiral codebase remains robust and consistent.
Please check off each taskbox as an acknowledgment that you completed the task or check off that it is not relevant to your Pull Request. This checklist is part of the Github Action workflows and the Pull Request will not be merged into the
main
branch until you have checked off each task.styler::style_file()
to style R and Rmd filesinst/cheatsheet/admiral_cheatsheet.pptx
and re-upload a PDF version of it to the same folder.devtools::document()
so all.Rd
files in theman
folder and theNAMESPACE
file in the project root are updated appropriatelyNEWS.md
under the header# admiral (development version)
if the changes pertain to a user-facing function (i.e. it has an@export
tag) or documentation aimed at users (rather than developers). A Developer Notes section is available inNEWS.md
for tracking developer-facing issues.pkgdown::build_site()
and check that all affected examples are displayed correctly and that all new functions occur on the "Reference" page.lintr::lint_package()
R CMD check
locally and address all errors and warnings -devtools::check()