-
Notifications
You must be signed in to change notification settings - Fork 8
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
base: main
Are you sure you want to change the base?
253 feature request deprecatesupersede derive vars crit #254
Conversation
R/derive_vars_crit.R
Outdated
#' @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 | ||
#' . |
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 @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
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 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!
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 @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 :)
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.styler::style_file()
to style R and Rmd filesdevtools::document()
so all.Rd
files in theman
folder and theNAMESPACE
file in the project root are updated appropriatelyNEWS.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)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()