diff --git a/DESCRIPTION b/DESCRIPTION index 97bba48a0a..2bd546bb77 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: admiral Title: ADaM in R Asset Library -Version: 1.1.1.9042 +Version: 1.1.1.9043 Authors@R: c( person("Ben", "Straub", , "ben.x.straub@gsk.com", role = c("aut", "cre")), person("Stefan", "Bundfuss", role = "aut", diff --git a/NEWS.md b/NEWS.md index f077231aab..cfa5d536bc 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,7 +5,7 @@ - New function `derive_vars_cat()` for deriving pairs of variables or more, e.g. `AVALCATy` & `AVALCAyN`. (#2480) - New function `derive_vars_crit_flag()` for deriving criterion flag variables -(`CRITy`, `CRITyFL`, `CRITyFLN`). (#2468) +(`CRITy`, `CRITyFL`, `CRITyFN`). (#2468) - New function `transform_range()` to transform values from a source range to a target range. (#2571) - Replace use of `data("sdtm")` with `sdtm <- pharmaverse::sdtm` in templates and vignettes. (#2498) diff --git a/R/derive_vars_crit_flag.R b/R/derive_vars_crit_flag.R index 2a2ba302bf..eeebe2d868 100644 --- a/R/derive_vars_crit_flag.R +++ b/R/derive_vars_crit_flag.R @@ -1,4 +1,4 @@ -#' Derive Criterion Flag Variables `CRITy`, `CRITyFL`, and `CRITyFLN` +#' Derive Criterion Flag Variables `CRITy`, `CRITyFL`, and `CRITyFN` #' #' @description #' @@ -49,12 +49,12 @@ #' *Permitted Values*: `TRUE`, `FALSE` #' @param create_numeric_flag Create a numeric flag? #' -#' If set to `TRUE`, the `CRITyFLN` variable is created. It is set to `1` if +#' If set to `TRUE`, the `CRITyFN` variable is created. It is set to `1` if #' `CRITyFL == "Y"`, it set to `0` if `CRITyFL == "N"`, and to `NA` otherwise. #' #' *Permitted Values*: `TRUE`, `FALSE` #' @return The input dataset with the variables `CRITy`, `CRITyFL`, and -#' optionally `CRITyFLN` added. +#' optionally `CRITyFN` added. #' #' @family der_bds_findings #' @keywords der_bds_findings @@ -110,10 +110,10 @@ derive_vars_crit_flag <- function(dataset, if (values_yn) { crityfl_no <- "N" - crityfln_no <- 0L + crityfn_no <- 0L } else { crityfl_no <- NA_character_ - crityfln_no <- NA_integer_ + crityfn_no <- NA_integer_ } tryCatch( @@ -154,9 +154,9 @@ derive_vars_crit_flag <- function(dataset, ) if (create_numeric_flag) { - new_critflnvar <- paste0("CRIT", as.character(crit_nr), "FLN") + new_critfnvar <- paste0("CRIT", as.character(crit_nr), "FN") dataset <- dataset %>% mutate( - !!new_critflnvar := yn_to_numeric(!!sym(new_critflvar)) + !!new_critfnvar := yn_to_numeric(!!sym(new_critflvar)) ) } dataset diff --git a/man/derive_vars_crit_flag.Rd b/man/derive_vars_crit_flag.Rd index 08c66399b7..0aabe6ec7f 100644 --- a/man/derive_vars_crit_flag.Rd +++ b/man/derive_vars_crit_flag.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/derive_vars_crit_flag.R \name{derive_vars_crit_flag} \alias{derive_vars_crit_flag} -\title{Derive Criterion Flag Variables \code{CRITy}, \code{CRITyFL}, and \code{CRITyFLN}} +\title{Derive Criterion Flag Variables \code{CRITy}, \code{CRITyFL}, and \code{CRITyFN}} \usage{ derive_vars_crit_flag( dataset, @@ -51,14 +51,14 @@ Otherwise, the \code{CRITyFL} variable is set to \code{"Y"} if the condition \item{create_numeric_flag}{Create a numeric flag? -If set to \code{TRUE}, the \code{CRITyFLN} variable is created. It is set to \code{1} if +If set to \code{TRUE}, the \code{CRITyFN} variable is created. It is set to \code{1} if \code{CRITyFL == "Y"}, it set to \code{0} if \code{CRITyFL == "N"}, and to \code{NA} otherwise. \emph{Permitted Values}: \code{TRUE}, \code{FALSE}} } \value{ The input dataset with the variables \code{CRITy}, \code{CRITyFL}, and -optionally \code{CRITyFLN} added. +optionally \code{CRITyFN} added. } \description{ The function derives ADaM compliant criterion flags, e.g., to facilitate diff --git a/tests/testthat/test-derive_vars_crit_flag.R b/tests/testthat/test-derive_vars_crit_flag.R index 4f97600dbf..dbd0708da8 100644 --- a/tests/testthat/test-derive_vars_crit_flag.R +++ b/tests/testthat/test-derive_vars_crit_flag.R @@ -21,10 +21,10 @@ test_that("derive_vars_crit_flag Test 1: works with defaults", { ## Test 2: create numeric flag ---- test_that("derive_vars_crit_flag Test 2: create numeric flag", { expected <- tibble::tribble( - ~AVAL, ~CRIT1FL, ~CRIT1FLN, ~CRIT1, - 23, NA_character_, NA_real_, NA_character_, - 42, "Y", 1, "AVAL > 40", - NA, NA_character_, NA_real_, NA_character_ + ~AVAL, ~CRIT1FL, ~CRIT1FN, ~CRIT1, + 23, NA_character_, NA_real_, NA_character_, + 42, "Y", 1, "AVAL > 40", + NA, NA_character_, NA_real_, NA_character_ ) expect_dfs_equal( @@ -42,12 +42,12 @@ test_that("derive_vars_crit_flag Test 2: create numeric flag", { ## Test 3: using values Y and N ---- test_that("derive_vars_crit_flag Test 3: using values Y and N", { expected <- tibble::tribble( - ~PARAMCD, ~AVAL, ~CRIT2FL, ~CRIT2FLN, ~CRIT2, - "AST", 23, "N", 0, "AST > 40", - "AST", 42, "Y", 1, "AST > 40", - "AST", NA, NA_character_, NA_real_, "AST > 40", - "ALT", 26, "N", 0, "ALT > 40", - "ALT", 56, "Y", 1, "ALT > 40", + ~PARAMCD, ~AVAL, ~CRIT2FL, ~CRIT2FN, ~CRIT2, + "AST", 23, "N", 0, "AST > 40", + "AST", 42, "Y", 1, "AST > 40", + "AST", NA, NA_character_, NA_real_, "AST > 40", + "ALT", 26, "N", 0, "ALT > 40", + "ALT", 56, "Y", 1, "ALT > 40", ) expect_dfs_equal( diff --git a/vignettes/bds_finding.Rmd b/vignettes/bds_finding.Rmd index 89255a017f..7e6632c0d6 100644 --- a/vignettes/bds_finding.Rmd +++ b/vignettes/bds_finding.Rmd @@ -45,7 +45,7 @@ otherwise specified.* * [Assign Treatment (`TRTA`, `TRTP`)](#treatment) * [Assign `ASEQ`](#aseq) * [Derive Categorization Variables (`AVALCATy`)](#cat) -* [Derive Criterion Variables (`CRITy`, `CRITyFL`, `CRITyFLN`)](#crit_vars) +* [Derive Criterion Variables (`CRITy`, `CRITyFL`, `CRITyFN`)](#crit_vars) * [Add ADSL variables](#adsl_vars) * [Derive New Rows](#additional) * [Add Labels and Attributes](#attributes) @@ -879,9 +879,9 @@ dataset_vignette( ) ``` -## Derive Criterion Variables (`CRITy`, `CRITyFL`, `CRITyFLN`) {#crit_vars} +## Derive Criterion Variables (`CRITy`, `CRITyFL`, `CRITyFN`) {#crit_vars} -For deriving criterion variables (`CRITy`, `CRITyFL`, `CRITyFLN`) `{admiral}` +For deriving criterion variables (`CRITy`, `CRITyFL`, `CRITyFN`) `{admiral}` provides `derive_vars_crit_flag()`. It ensures that they are derived in an ADaM-compliant way (see documentation of the function for details). @@ -921,7 +921,7 @@ advs <- advs %>% ```{r, eval=TRUE, echo=FALSE} dataset_vignette( arrange(advs, USUBJID, AVISITN, ATPTN, PARAMCD), - display_vars = exprs(USUBJID, PARAMCD, AVAL, CHG, CRIT1, CRIT1FL, CRIT1FLN), + display_vars = exprs(USUBJID, PARAMCD, AVAL, CHG, CRIT1, CRIT1FL, CRIT1FN), filter = PARAMCD %in% c("DIABP", "SYSBP") ) ``` @@ -946,7 +946,7 @@ advs <- advs %>% ```{r, eval=TRUE, echo=FALSE} dataset_vignette( arrange(advs, USUBJID, AVISITN, ATPTN), - display_vars = exprs(USUBJID, PARAMCD, AVAL, CHG, CRIT2, CRIT2FL, CRIT2FLN), + display_vars = exprs(USUBJID, PARAMCD, AVAL, CHG, CRIT2, CRIT2FL, CRIT2FN), filter = PARAMCD == "SYSBP" ) ```