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

253 feature request deprecatesupersede derive vars crit #254

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

federicobaratin
Copy link
Collaborator

@federicobaratin federicobaratin commented Dec 12, 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 devel 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 - See Unit Test Guide
  • If you removed/replaced any function and/or function parameters, did you fully follow the deprecation guidance?
  • Update to all relevant roxygen headers and examples.
  • 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 if the changes pertain to a user-facing function (i.e. it has an @export tag) or documentation aimed at users (rather than developers)
  • 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 so that it closes after successful merging.
  • Address all merge conflicts and resolve appropriately.
  • Pat yourself on the back for a job well done! Much love to your accomplishment!

@federicobaratin federicobaratin added documentation Improvements or additions to documentation enhancement New feature or request final review Addressing comments from the final review of Admiral team labels Dec 12, 2024
@federicobaratin federicobaratin self-assigned this Dec 12, 2024
@federicobaratin federicobaratin linked an issue Dec 12, 2024 that may be closed by this pull request
@ahasoplakus ahasoplakus requested review from ahasoplakus and manciniedoardo and removed request for vikrams95 December 12, 2024 14:37
Comment on lines 6 to 13
#' @export
#' @keywords der_var
#' @family der_var
#'
#' @examples
#' library(tibble)
#' library(admiral)
#' library(admiraldev)
#' library(dplyr)
#'
#' input <- tribble(
#' ~USUBJID, ~AVISITN, ~ISCAT, ~PARAMCD, ~AVAL, ~ISLLOQ,
#' "999999-000001", 10, "IMMUNOLOGY", "J0033VN", 2, 4,
#' "999999-000001", 10, "IMMUNOLOGY", "I0019NT", 3, 6,
#' "999999-000001", 10, "IMMUNOLOGY", "M0019LN", 4, 4,
#' "999999-000001", 10, "IMMUNOLOGY", "R0003MA", 3, 6,
#' "999999-000001", 30, "IMMUNOLOGY", "J0033VN", 60, 4,
#' "999999-000001", 30, "IMMUNOLOGY", "I0019NT", 567, 6,
#' "999999-000001", 30, "IMMUNOLOGY", "M0019LN", 659, 4,
#' "999999-000001", 30, "IMMUNOLOGY", "R0003MA", 250, 6,
#' "999999-000002", 10, "IMMUNOLOGY", "J0033VN", 2, 4,
#' "999999-000002", 10, "IMMUNOLOGY", "I0019NT", 7, 6,
#' "999999-000002", 10, "IMMUNOLOGY", "M0019LN", 5, 4,
#' "999999-000002", 10, "IMMUNOLOGY", "R0003MA", 3, 6,
#' "999999-000002", 30, "IMMUNOLOGY", "J0033VN", 55, 4,
#' "999999-000002", 30, "IMMUNOLOGY", "I0019NT", 89, 6,
#' "999999-000002", 30, "IMMUNOLOGY", "M0019LN", 990, 4,
#' "999999-000002", 30, "IMMUNOLOGY", "R0003MA", 340, 6,
#' "999999-000003", 10, "IMMUNOLOGY", "J0033VN", 3, 4,
#' "999999-000003", 10, "IMMUNOLOGY", "I0019NT", 6, 6,
#' "999999-000003", 10, "IMMUNOLOGY", "M0019LN", 2, 4,
#' "999999-000003", 10, "IMMUNOLOGY", "R0003MA", 2, 6,
#' "999999-000003", 30, "IMMUNOLOGY", "J0033VN", 45, 4,
#' "999999-000003", 30, "IMMUNOLOGY", "I0019NT", 381, 6,
#' "999999-000003", 30, "IMMUNOLOGY", "M0019LN", 542, 4,
#' "999999-000003", 30, "IMMUNOLOGY", "R0003MA", NA, 6
#' )
#'
#'
#' derive_vars_crit(
#' dataset = input,
#' prefix = "CRIT1",
#' crit_label = "Titer >= ISLLOQ",
#' condition = !is.na(AVAL) & !is.na(ISLLOQ),
#' criterion = AVAL >= ISLLOQ
#' )
#'
derive_vars_crit <- function(dataset, prefix, crit_label, condition, criterion) {
condition <- assert_filter_cond(enquo(condition))
criterion <- assert_filter_cond(enquo(criterion))

var_char <- paste0(prefix, "FL")
var_num <- paste0(prefix, "FN")

if (grepl("CRIT", prefix)) {
data <- dataset %>%
mutate(
`:=`(
!!var_char,
case_when(
!(!!condition) ~ NA_character_,
!!criterion & !!condition ~ "Y",
!(!!criterion) & !!condition ~ "N"
)
),
`:=`(
!!var_num,
case_when(
!(!!condition) ~ NA_real_,
!!criterion & !!condition ~ 1,
!(!!criterion) & !!condition ~ 0
)
),
`:=`(
!!prefix,
case_when(
!(!!condition) ~ NA_character_,
!!criterion & !!condition ~ crit_label,
!(!!criterion) & !!condition ~ crit_label
)
)
)
} else {
data <- dataset %>%
mutate(
`:=`(
!!var_char,
case_when(
!(!!condition) ~ NA_character_,
!!criterion & !!condition ~ "Y",
!(!!criterion) & !!condition ~ "N"
)
)
)
}

return(data)
}
#' @keywords deprecated
#' .
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi @federicobaratin Thanks for making the changes. Instead of completely removing the function please adhere to the deprecation strategy for admiral packages as mentioned here https://pharmaverse.github.io/admiraldev/articles/programming_strategy.html#deprecation

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi Sukalpo, I have updated the function description.
I followed the strategy, by updating relative fields (function description, family and keywords) and removed examples, as suggested. Thanks!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi @ahasoplakus, I have corrected most of the errors and now both ADIS template and vignette are fine. Same for the admiralvaccine function that need to be deprecated.
I think one link need to be updated in ADFACE. If you provide me the correct one, I can update it for you.
The other issue is that ADIS template does not recognize the new admiral function.
Please, let me know :)

Copy link

github-actions bot commented Dec 12, 2024

Code Coverage

Package Line Rate Health
admiralvaccine 99%
Summary 99% (374 / 377)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request final review Addressing comments from the final review of Admiral team
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Feature Request: deprecate/supersede derive_vars_crit()
2 participants