diff --git a/R/derive_param_tte.R b/R/derive_param_tte.R index 3021d0da9b..26ccefc632 100644 --- a/R/derive_param_tte.R +++ b/R/derive_param_tte.R @@ -67,7 +67,7 @@ #' by variables and the date and order specified in the `event_source()` and #' `censor_source()` objects. #' -#' *Permitted Values*: `"none"`, `"message"`, `"warning"`, `"error"` +#' *Permitted Values*: `"none"`, `"message"`, `"warning"`, `"error"` #' #' @details The following steps are performed to create the observations of the #' new parameter: @@ -271,10 +271,10 @@ #' mutate(STUDYID = "AB42") #' #' ae <- tribble( -#' ~USUBJID, ~AESTDTC, ~AESEQ, ~AEDECOD, -#' "01", "2021-01-03T10:56", 1, "Flu", -#' "01", "2021-03-04", 2, "Cough", -#' "01", "2021", 3, "Flu" +#' ~USUBJID, ~AESTDTC, ~AESEQ, ~AEDECOD, +#' "01", "2021-01-03T10:56", 1, "Flu", +#' "01", "2021-03-04", 2, "Cough", +#' "01", "2021", 3, "Flu" #' ) %>% #' mutate(STUDYID = "AB42") #' @@ -325,16 +325,16 @@ #' #' # Resolve tie when serious AE share a date by sorting with order argument #' adsl <- tribble( -#' ~USUBJID, ~TRTSDT, ~EOSDT, -#' "01", ymd("2020-12-06"), ymd("2021-03-06"), -#' "02", ymd("2021-01-16"), ymd("2021-02-03") +#' ~USUBJID, ~TRTSDT, ~EOSDT, +#' "01", ymd("2020-12-06"), ymd("2021-03-06"), +#' "02", ymd("2021-01-16"), ymd("2021-02-03") #' ) %>% mutate(STUDYID = "AB42") #' #' ae <- tribble( -#' ~USUBJID, ~AESTDTC, ~AESEQ, ~AESER, ~AEDECOD, -#' "01", "2021-01-03", 1, "Y", "Flu", -#' "01", "2021-01-03", 2, "Y", "Cough", -#' "01", "2021-01-20", 3, "N", "Headache", +#' ~USUBJID, ~AESTDTC, ~AESEQ, ~AESER, ~AEDECOD, +#' "01", "2021-01-03", 1, "Y", "Flu", +#' "01", "2021-01-03", 2, "Y", "Cough", +#' "01", "2021-01-20", 3, "N", "Headache" #' ) %>% mutate( #' AESTDT = ymd(AESTDTC), #' STUDYID = "AB42" @@ -565,7 +565,7 @@ derive_param_tte <- function(dataset = NULL, #' respect to the date is included in the output dataset. If `"last"` is #' specified, the last observation is included in the output dataset. #' -#' Permitted Values: `"first"`, `"last"` +#' *Permitted Values*: `"first"`, `"last"` #' #' @param check_type Check uniqueness #' @@ -573,8 +573,7 @@ derive_param_tte <- function(dataset = NULL, #' if the observations of the source datasets are not unique with respect to the #' by variables and the date and order specified in the `tte_source()` objects. #' -#' Default: `"none"` -#' Permitted Values: `"none"`, `"warning"`, `"error"`, `"message"` +#' *Permitted Values*: `"none"`, `"warning"`, `"error"`, `"message"` #' #' @details The following steps are performed to create the output dataset: #' @@ -701,9 +700,12 @@ filter_date_sources <- function(sources, duplicate_records = function(cnd) { cnd_funs <- list(message = cli_inform, warning = cli_warn, error = cli_abort) cnd_funs[[check_type]]( - paste( - "Dataset {.val {sources[[i]]$dataset_name}} contains duplicate records with respect to", - "{.var {cnd$by_vars}}" + c( + paste( + "Dataset {.val {sources[[i]]$dataset_name}} contains duplicate records with respect to", + "{.var {cnd$by_vars}}" + ), + i = "Run {.run admiral::get_duplicates_dataset()} to access the duplicate records" ), class = class(cnd)) cnd_muffle(cnd) diff --git a/man/derive_param_tte.Rd b/man/derive_param_tte.Rd index ae70f7e02b..a835ca3110 100644 --- a/man/derive_param_tte.Rd +++ b/man/derive_param_tte.Rd @@ -288,10 +288,10 @@ adsl <- tribble( mutate(STUDYID = "AB42") ae <- tribble( - ~USUBJID, ~AESTDTC, ~AESEQ, ~AEDECOD, - "01", "2021-01-03T10:56", 1, "Flu", - "01", "2021-03-04", 2, "Cough", - "01", "2021", 3, "Flu" + ~USUBJID, ~AESTDTC, ~AESEQ, ~AEDECOD, + "01", "2021-01-03T10:56", 1, "Flu", + "01", "2021-03-04", 2, "Cough", + "01", "2021", 3, "Flu" ) \%>\% mutate(STUDYID = "AB42") @@ -342,16 +342,16 @@ derive_param_tte( # Resolve tie when serious AE share a date by sorting with order argument adsl <- tribble( - ~USUBJID, ~TRTSDT, ~EOSDT, - "01", ymd("2020-12-06"), ymd("2021-03-06"), - "02", ymd("2021-01-16"), ymd("2021-02-03") + ~USUBJID, ~TRTSDT, ~EOSDT, + "01", ymd("2020-12-06"), ymd("2021-03-06"), + "02", ymd("2021-01-16"), ymd("2021-02-03") ) \%>\% mutate(STUDYID = "AB42") ae <- tribble( - ~USUBJID, ~AESTDTC, ~AESEQ, ~AESER, ~AEDECOD, - "01", "2021-01-03", 1, "Y", "Flu", - "01", "2021-01-03", 2, "Y", "Cough", - "01", "2021-01-20", 3, "N", "Headache", + ~USUBJID, ~AESTDTC, ~AESEQ, ~AESER, ~AEDECOD, + "01", "2021-01-03", 1, "Y", "Flu", + "01", "2021-01-03", 2, "Y", "Cough", + "01", "2021-01-20", 3, "N", "Headache" ) \%>\% mutate( AESTDT = ymd(AESTDTC), STUDYID = "AB42" diff --git a/man/filter_date_sources.Rd b/man/filter_date_sources.Rd index d411ec9e1e..3696d7c8c3 100644 --- a/man/filter_date_sources.Rd +++ b/man/filter_date_sources.Rd @@ -47,7 +47,7 @@ If \code{"first"} is specified, for each subject the first observation with respect to the date is included in the output dataset. If \code{"last"} is specified, the last observation is included in the output dataset. -Permitted Values: \code{"first"}, \code{"last"}} +\emph{Permitted Values}: \code{"first"}, \code{"last"}} \item{check_type}{Check uniqueness @@ -55,8 +55,7 @@ If \code{"warning"}, \code{"message"}, or \code{"error"} is specified, the speci if the observations of the source datasets are not unique with respect to the by variables and the date and order specified in the \code{tte_source()} objects. -Default: \code{"none"} -Permitted Values: \code{"none"}, \code{"warning"}, \code{"error"}, \code{"message"}} +\emph{Permitted Values}: \code{"none"}, \code{"warning"}, \code{"error"}, \code{"message"}} } \value{ A dataset with one observation per subject as described in the diff --git a/tests/testthat/_snaps/derive_param_tte.md b/tests/testthat/_snaps/derive_param_tte.md index 8bf79977a6..0891d2492b 100644 --- a/tests/testthat/_snaps/derive_param_tte.md +++ b/tests/testthat/_snaps/derive_param_tte.md @@ -70,6 +70,7 @@ Condition Warning: Dataset "ae" contains duplicate records with respect to `STUDYID`, `USUBJID`, and `AESTDT` + i Run `admiral::get_duplicates_dataset()` to access the duplicate records Output # A tibble: 2 x 10 USUBJID STUDYID EVENTDESC SRCDOM SRCVAR SRCSEQ CNSR ADT STARTDT diff --git a/tests/testthat/test-derive_param_tte.R b/tests/testthat/test-derive_param_tte.R index e676b2bdc7..73e17e1def 100644 --- a/tests/testthat/test-derive_param_tte.R +++ b/tests/testthat/test-derive_param_tte.R @@ -932,7 +932,7 @@ test_that("derive_param_tte Test 13: error if dataset_name not in source_datsets ) }) -## Test 14: derive_param_tte detects duplicates when check_type = 'warning' ---- +## Test 14: detects duplicates in input datasets via pipeline functions ---- test_that("derive_param_tte Test 14: detects duplicates in input datasets via pipeline functions", { # Define ADSL dataset adsl <- tibble::tribble( @@ -989,9 +989,8 @@ test_that("derive_param_tte Test 14: detects duplicates in input datasets via pi ) }) -## Test 15: derive_param_tte resolves ties using order argument when input is sorted descending -test_that("derive_param_tte Test 15: derive_param_tte resolves ties using order argument when -input is sorted descending", { +## Test 15: using order for resolving ties ---- +test_that("derive_param_tte Test 15: using order for resolving ties", { adsl <- tibble::tribble( ~USUBJID, ~TRTSDT, ~EOSDT, "01", ymd("2020-12-06"), ymd("2021-03-06"), @@ -1049,7 +1048,7 @@ input is sorted descending", { is chosen on tie.") }) -## Test 16: derive_param_tte produces consistent results regardless of input sort order ---- +## Test 16: produces consistent results regardless of input sort order ---- test_that("derive_param_tte Test 16: produces consistent results regardless of input sort order", { # Define ADSL dataset adsl <- tibble::tribble(