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 #2510 enhance derive param computed #2544

Merged
merged 6 commits into from
Nov 7, 2024

Conversation

bundfussr
Copy link
Collaborator

@bundfussr bundfussr commented Oct 29, 2024

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!

@bundfussr bundfussr linked an issue Oct 29, 2024 that may be closed by this pull request
Copy link

github-actions bot commented Oct 29, 2024

Code Coverage

Package Line Rate Health
admiral 97%
Summary 97% (4978 / 5140)

_pkgdown.yml Outdated
@@ -1,6 +1,7 @@
url: https://pharmaverse.github.io/admiral

template:
math-rendering: mathjax
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this intentional? Just checking!?! :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I rendered the documentation with pkgdown 2.1.1 and noticed that formulas are no longer rendered correctly. Adding this line fixes the issues.

@bms63
Copy link
Collaborator

bms63 commented Oct 29, 2024

@yurovska does this meet your needs for this function?

@yurovska
Copy link

yurovska commented Oct 29, 2024

@yurovska does this meet your needs for this function?

@bms63 @bundfussr Yes, sort of... It indeed gives a possibility to do what I wanted to do as described in the issue. However, users might still be falling into a trap if keep_nas is omitted in the call (which is exactly what you'd do in the first place) and the function will simply return the input dataset with no new parameters added if one of the variables used in set_values_to is populated with NA.

advs <- tribble(
  ~USUBJID,      ~PARAMCD, ~PARAM,        ~AVAL, ~AVALU, ~VISIT,      ~TESTVAR,
  "01-701-1015", "HEIGHT", "Height (cm)", 147.0, "cm",   "SCREENING", NA_character_,
  "01-701-1015", "WEIGHT", "Weight (kg)",  54.0, "kg",   "SCREENING", NA_character_,
  "01-701-1015", "WEIGHT", "Weight (kg)",  54.4, "kg",   "BASELINE",  NA_character_,
  "01-701-1015", "WEIGHT", "Weight (kg)",  53.1, "kg",   "WEEK 2",    NA_character_,
  "01-701-1028", "HEIGHT", "Height (cm)", 163.0, "cm",   "SCREENING", NA_character_,
  "01-701-1028", "WEIGHT", "Weight (kg)",  78.5, "kg",   "SCREENING", NA_character_,
  "01-701-1028", "WEIGHT", "Weight (kg)",  80.3, "kg",   "BASELINE",  NA_character_,
  "01-701-1028", "WEIGHT", "Weight (kg)",  80.7, "kg",   "WEEK 2",    NA_character_
)

derive_param_computed(
  dataset = advs,
  by_vars = exprs(USUBJID, VISIT),
  parameters = "WEIGHT",
  set_values_to = exprs(
    AVAL = AVAL.WEIGHT / (AVAL.HEIGHT / 100)^2,
    AVALU = "kg/m^2",
    PARAMCD = "BMI",
    PARAM = "Body Mass Index (kg/m^2)",
    TESTVAR = TESTVAR.WEIGHT
  ),
  constant_parameters = c("HEIGHT"),
  constant_by_vars = exprs(USUBJID)
)
# A tibble: 8 × 7
  USUBJID     PARAMCD PARAM        AVAL AVALU VISIT     TESTVAR
  <chr>       <chr>   <chr>       <dbl> <chr> <chr>     <chr>  
1 01-701-1015 HEIGHT  Height (cm) 147   cm    SCREENING NA     
2 01-701-1015 WEIGHT  Weight (kg)  54   kg    SCREENING NA     
3 01-701-1015 WEIGHT  Weight (kg)  54.4 kg    BASELINE  NA     
4 01-701-1015 WEIGHT  Weight (kg)  53.1 kg    WEEK 2    NA     
5 01-701-1028 HEIGHT  Height (cm) 163   cm    SCREENING NA     
6 01-701-1028 WEIGHT  Weight (kg)  78.5 kg    SCREENING NA     
7 01-701-1028 WEIGHT  Weight (kg)  80.3 kg    BASELINE  NA     
8 01-701-1028 WEIGHT  Weight (kg)  80.7 kg    WEEK 2    NA     

Shall derive_param_computed at least check if it derived anything before returning the result and, if not, throw a sort of cli_alert_info of something like that?

@bundfussr
Copy link
Collaborator Author

Shall derive_param_computed at least check if it derived anything before returning the result and, if not, throw a sort of cli_alert_info of something like that?

Yes, good idea.
I've added a cli_inform() if no records were added due to NAs in contributing values.

@yurovska
Copy link

Shall derive_param_computed at least check if it derived anything before returning the result and, if not, throw a sort of cli_alert_info of something like that?

Yes, good idea. I've added a cli_inform() if no records were added due to NAs in contributing values.

Awesome. It is much more clear for the user now. Thanks a lot!

No more comments from my side. Good job @bundfussr!

@bundfussr bundfussr requested a review from bms63 November 7, 2024 11:38
NEWS.md Show resolved Hide resolved
@bms63 bms63 merged commit e9efced into main Nov 7, 2024
19 checks passed
@bms63 bms63 deleted the 2510_enhance_derive_param_computed branch November 7, 2024 19:56
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.

Bug: derive_param_computed() does nothing
3 participants