Skip to content

Commit

Permalink
#2481: cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
bundfussr committed Jan 13, 2025
1 parent 9980980 commit 961bdbe
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 37 deletions.
38 changes: 20 additions & 18 deletions R/derive_param_tte.R
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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")
#'
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -565,16 +565,15 @@ 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
#'
#' If `"warning"`, `"message"`, or `"error"` is specified, the specified message is issued
#' 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:
#'
Expand Down Expand Up @@ -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)
Expand Down
22 changes: 11 additions & 11 deletions man/derive_param_tte.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions man/filter_date_sources.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tests/testthat/_snaps/derive_param_tte.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions tests/testthat/test-derive_param_tte.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 961bdbe

Please sign in to comment.