Skip to content

Closes #2652 derive_vars_joined_summary: Implement derive_vars_joined_summary()#2720

Merged
bms63 merged 28 commits intomainfrom
2652_derive_vars_joined_summary
May 23, 2025
Merged

Closes #2652 derive_vars_joined_summary: Implement derive_vars_joined_summary()#2720
bms63 merged 28 commits intomainfrom
2652_derive_vars_joined_summary

Conversation

@bundfussr
Copy link
Copy Markdown
Collaborator

@bundfussr bundfussr commented May 7, 2025

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.

  • Place Closes #<insert_issue_number> into the beginning of your Pull Request Title (Use Edit button in top-right if you need to update)
  • Code is formatted according to the tidyverse style guide. Run styler::style_file() to style R and Rmd files
  • Updated relevant unit tests or have written new unit tests, which should consider realistic data scenarios and edge cases, e.g. empty datasets, errors, boundary cases etc. - See Unit Test Guide
  • If you removed/replaced any function and/or function parameters, did you fully follow the deprecation guidance?
  • Review the Cheat Sheet. Make any required updates to it by editing the file inst/cheatsheet/admiral_cheatsheet.pptx and re-upload a PDF and a PNG version of it to the same folder. (The PNG version can be created by taking a screenshot of the PDF version.)
  • Update to all relevant roxygen headers and examples, including keywords and families. Refer to the categorization of functions to tag appropriate keyword/family.
  • Run devtools::document() so all .Rd files in the man folder and the NAMESPACE file in the project root are updated appropriately
  • Address any updates needed for vignettes and/or templates
  • Update NEWS.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 in NEWS.md for tracking developer-facing issues.
  • Build admiral site pkgdown::build_site() and check that all affected examples are displayed correctly and that all new functions occur on the "Reference" page.
  • Address or fix all lintr warnings and errors - lintr::lint_package()
  • Run R CMD check locally and address all errors and warnings - devtools::check()
  • Link the issue in the Development Section on the right hand side.
  • Address all merge conflicts and resolve appropriately
  • Pat yourself on the back for a job well done! Much love to your accomplishment!

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2025

Code Coverage

Package Line Rate Health
admiral 98%
Summary 98% (5470 / 5575)

@bundfussr
Copy link
Copy Markdown
Collaborator Author

pharmaverse/admiraldev#491 needs to be merged to fix the failing man check.

Copy link
Copy Markdown
Collaborator

@manciniedoardo manciniedoardo left a comment

Choose a reason for hiding this comment

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

@bundfussr This looks great! I've tested the examples and given feedback, however I have not done a tech review.

Comment thread R/derive_vars_joined_summary.R
Comment thread R/derive_vars_joined_summary.R
Comment thread R/derive_vars_joined_summary.R Outdated
Comment thread R/derive_vars_joined_summary.R
Comment thread R/derive_vars_joined_summary.R Outdated
@bundfussr bundfussr requested a review from manciniedoardo May 14, 2025 10:21
Comment thread R/derive_vars_joined_summary.R Outdated
Copy link
Copy Markdown
Collaborator

@manciniedoardo manciniedoardo left a comment

Choose a reason for hiding this comment

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

@bundfussr looks good to me, just suggested a typo fix. awaiting a tech review before merging.

@bundfussr
Copy link
Copy Markdown
Collaborator Author

@manciniedoardo , I have added examples for join_type = "before" and first_cond_upper. Please have a look.

Copy link
Copy Markdown
Collaborator

@manciniedoardo manciniedoardo left a comment

Choose a reason for hiding this comment

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

One minor comment @bundfussr - looks great otherwise!

Comment thread R/derive_vars_joined_summary.R Outdated
@manciniedoardo
Copy link
Copy Markdown
Collaborator

@manciniedoardo , I have added examples for join_type = "before" and first_cond_upper. Please have a look.

@rossfarrugia FYI - you may wish to reference the simple examples for join_type and first_cond_* in the new derive_vars_joined() documentation? We have a few examples in various nplaces now but I guess it's about finding a balance to not make any of the pages too long!

@rossfarrugia
Copy link
Copy Markdown
Collaborator

@rossfarrugia FYI - you may wish to reference the simple examples for join_type and first_cond_* in the new derive_vars_joined() documentation? We have a few examples in various nplaces now but I guess it's about finding a balance to not make any of the pages too long!

I'd guess it will already get linked in the "See also" section so i personally wouldn't add more links, as i already have examples covering these arguments. I think users will get dizzy if we have them too often having to flick from page to page within the same package. I sometimes feel like that with Wikipedia where it's easy to find yourself in a hole and you forget where you started 😆

@manciniedoardo
Copy link
Copy Markdown
Collaborator

@rossfarrugia FYI - you may wish to reference the simple examples for join_type and first_cond_* in the new derive_vars_joined() documentation? We have a few examples in various nplaces now but I guess it's about finding a balance to not make any of the pages too long!

I'd guess it will already get linked in the "See also" section so i personally wouldn't add more links, as i already have examples covering these arguments. I think users will get dizzy if we have them too often having to flick from page to page within the same package. I sometimes feel like that with Wikipedia where it's easy to find yourself in a hole and you forget where you started 😆

Makes sense!

@manciniedoardo manciniedoardo self-requested a review May 21, 2025 09:17
Comment thread R/derive_vars_joined_summary.R
@bms63
Copy link
Copy Markdown
Collaborator

bms63 commented May 22, 2025

@bundfussr Not sure what happened with the templates - they passed in the other PR

I added EXENDTM to join_vars and it is working.

image

Comment thread vignettes/occds.Rmd
Comment on lines -282 to -285
order = exprs(EXSTDTM),
filter_add = (EXDOSE > 0 | (EXDOSE == 0 & grepl("PLACEBO", EXTRT))) & !is.na(EXSTDTM),
filter_join = EXSTDTM <= ASTDTM & (ASTDTM <= EXENDTM | is.na(EXENDTM)),
mode = "first"
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Hi @rossfarrugia , I slightly modified your DOSEON example such that it fails if multiple exposure records are found for an AE. I think in this case we shouldn't just take the first one but the programmer should take the decision how to handle it.

Do you agree?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

yes fine by me, i was thinking of similar at first as the spec for this one wasn't really clear but then i instead went with making it more likely to always run ok. would you add a note on this to the vignette above the code extract just to explain this? i think it would be useful for users to consider.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

FYI @bms63

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

would you add a note on this to the vignette above the code extract just to explain this? i think it would be useful for users to consider.

Good idea. Note added.

@bundfussr
Copy link
Copy Markdown
Collaborator Author

@bundfussr Not sure what happened with the templates - they passed in the other PR

I added EXENDTM to join_vars and it is working.

I think in the last release we introduced a minor "bug". By mistake, all variables of dataset_add were joined. Therefore it didn't matter when you forgot to specify a variable in join_vars. This doesn't produce wrong results but increases the memory consumption and reduces the performance. I have restored the previous behavior in this PR (see line 1134 in derive_joined.R).

@bms63
Copy link
Copy Markdown
Collaborator

bms63 commented May 23, 2025

Yay!! new function - so I fixed some merge conflicts but then the man check failed. we should discuss as next meeting as i guess i did something wrong!?!?!

@bms63 bms63 merged commit ecac7ec into main May 23, 2025
19 checks passed
@bms63 bms63 deleted the 2652_derive_vars_joined_summary branch May 23, 2025 19:16
@bundfussr
Copy link
Copy Markdown
Collaborator Author

Yay!! new function - so I fixed some merge conflicts but then the man check failed. we should discuss as next meeting as i guess i did something wrong!?!?!

It looks like you just forgot to update man after fixing the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Investigate if derive_vars_joined() to create CDISC derivation DOSCUMA

4 participants