Skip to content

Commit

Permalink
#1960 enhance_derive_extreme_event: style files
Browse files Browse the repository at this point in the history
  • Loading branch information
bundfussr committed Jul 18, 2023
1 parent a592b92 commit 246dd9f
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 95 deletions.
14 changes: 7 additions & 7 deletions R/derive_extreme_event.R
Original file line number Diff line number Diff line change
Expand Up @@ -410,13 +410,13 @@ event <- function(dataset_name = NULL,
#'
#' @return An object of class `event_joined`
event_joined <- function(dataset_name = NULL,
condition,
order = NULL,
join_vars,
join_type,
first_cond = NULL,
set_values_to = NULL,
keep_vars_source = NULL) {
condition,
order = NULL,
join_vars,
join_type,
first_cond = NULL,
set_values_to = NULL,
keep_vars_source = NULL) {
out <- list(
dataset_name = assert_character_scalar(dataset_name, optional = TRUE),
condition = assert_filter_cond(enexpr(condition), optional = TRUE),
Expand Down
1 change: 1 addition & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ summarization
th
thromboplastin
tidyverse
tidyselect
timeframe
timepart
timepoint
Expand Down
174 changes: 86 additions & 88 deletions tests/testthat/test-derive_extreme_event.R
Original file line number Diff line number Diff line change
Expand Up @@ -280,64 +280,64 @@ test_that("derive_extreme_records Test 3: `source_datasets` works", {

## Test 4: event_joined() is handled correctly ----
test_that("derive_extreme_records Test 4: event_joined() is handled correctly", {
adsl <- tibble::tribble(
~USUBJID, ~TRTSDTC,
"1", "2020-01-01",
"2", "2019-12-12",
"3", "2019-11-11",
"4", "2019-12-30",
"5", "2020-01-01",
"6", "2020-02-02",
"7", "2020-02-02",
"8", "2020-04-01",
"9", "2020-02-01"
) %>%
mutate(
TRTSDT = lubridate::ymd(TRTSDTC),
STUDYID = "XX1234"
)
adsl <- tibble::tribble(
~USUBJID, ~TRTSDTC,
"1", "2020-01-01",
"2", "2019-12-12",
"3", "2019-11-11",
"4", "2019-12-30",
"5", "2020-01-01",
"6", "2020-02-02",
"7", "2020-02-02",
"8", "2020-04-01",
"9", "2020-02-01"
) %>%
mutate(
TRTSDT = lubridate::ymd(TRTSDTC),
STUDYID = "XX1234"
)

adrs <- tibble::tribble(
~USUBJID, ~ADTC, ~AVALC,
"1", "2020-01-01", "PR",
"1", "2020-02-01", "CR",
"1", "2020-02-16", "NE",
"1", "2020-03-01", "CR",
"1", "2020-04-01", "SD",
"2", "2020-01-01", "SD",
"2", "2020-02-01", "PR",
"2", "2020-03-01", "SD",
"2", "2020-03-13", "CR",
"3", "2019-11-12", "CR",
"3", "2019-12-02", "CR",
"3", "2020-01-01", "SD",
"4", "2020-01-01", "PR",
"4", "2020-03-01", "SD",
"4", "2020-04-01", "SD",
"4", "2020-05-01", "PR",
"4", "2020-05-15", "NON-CR/NON-PD",
"5", "2020-01-01", "PR",
"5", "2020-01-10", "SD",
"5", "2020-01-20", "PR",
"5", "2020-05-15", "NON-CR/NON-PD",
"6", "2020-02-06", "PR",
"6", "2020-02-16", "CR",
"6", "2020-03-30", "PR",
"7", "2020-02-06", "PR",
"7", "2020-02-16", "CR",
"7", "2020-04-01", "NE",
"9", "2020-02-16", "PD"
) %>%
mutate(
PARAMCD = "OVR",
ADT = lubridate::ymd(ADTC),
STUDYID = "XX1234"
adrs <- tibble::tribble(
~USUBJID, ~ADTC, ~AVALC,
"1", "2020-01-01", "PR",
"1", "2020-02-01", "CR",
"1", "2020-02-16", "NE",
"1", "2020-03-01", "CR",
"1", "2020-04-01", "SD",
"2", "2020-01-01", "SD",
"2", "2020-02-01", "PR",
"2", "2020-03-01", "SD",
"2", "2020-03-13", "CR",
"3", "2019-11-12", "CR",
"3", "2019-12-02", "CR",
"3", "2020-01-01", "SD",
"4", "2020-01-01", "PR",
"4", "2020-03-01", "SD",
"4", "2020-04-01", "SD",
"4", "2020-05-01", "PR",
"4", "2020-05-15", "NON-CR/NON-PD",
"5", "2020-01-01", "PR",
"5", "2020-01-10", "SD",
"5", "2020-01-20", "PR",
"5", "2020-05-15", "NON-CR/NON-PD",
"6", "2020-02-06", "PR",
"6", "2020-02-16", "CR",
"6", "2020-03-30", "PR",
"7", "2020-02-06", "PR",
"7", "2020-02-16", "CR",
"7", "2020-04-01", "NE",
"9", "2020-02-16", "PD"
) %>%
derive_vars_merged(
dataset_add = adsl,
by_vars = exprs(STUDYID, USUBJID),
new_vars = exprs(TRTSDT)
)
mutate(
PARAMCD = "OVR",
ADT = lubridate::ymd(ADTC),
STUDYID = "XX1234"
) %>%
derive_vars_merged(
dataset_add = adsl,
by_vars = exprs(STUDYID, USUBJID),
new_vars = exprs(TRTSDT)
)

actual <-
derive_extreme_event(
Expand Down Expand Up @@ -411,45 +411,43 @@ adrs <- tibble::tribble(
),
keep_vars_source = exprs(TRTSDT)
)

),
set_values_to = exprs(
PARAMCD = "CBOR",
PARAM = "Best Confirmed Overall Response by Investigator"
)
)

expected <- bind_rows(
adrs,
tibble::tribble(
~USUBJID, ~ADTC, ~AVALC,
"1", "2020-02-01", "CR",
"2", "2020-02-01", "SD",
"3", "2020-01-01", "SD",
"4", "2020-03-01", "SD",
"5", "2020-05-15", "NON-CR/NON-PD",
"6", "2020-03-30", "SD",
"7", "2020-02-06", "NE",
"8", NA_character_, "MISSING",
"9", "2020-02-16", "PD"
) %>%
mutate(
ADT = lubridate::ymd(ADTC),
STUDYID = "XX1234",
PARAMCD = "CBOR",
PARAM = "Best Confirmed Overall Response by Investigator"
expected <- bind_rows(
adrs,
tibble::tribble(
~USUBJID, ~ADTC, ~AVALC,
"1", "2020-02-01", "CR",
"2", "2020-02-01", "SD",
"3", "2020-01-01", "SD",
"4", "2020-03-01", "SD",
"5", "2020-05-15", "NON-CR/NON-PD",
"6", "2020-03-30", "SD",
"7", "2020-02-06", "NE",
"8", NA_character_, "MISSING",
"9", "2020-02-16", "PD"
) %>%
derive_vars_merged(
dataset_add = adsl,
by_vars = exprs(STUDYID, USUBJID),
new_vars = exprs(TRTSDT)
)
)

expect_dfs_equal(
base = expected,
compare = actual,
keys = c("USUBJID", "PARAMCD", "ADT")
)
mutate(
ADT = lubridate::ymd(ADTC),
STUDYID = "XX1234",
PARAMCD = "CBOR",
PARAM = "Best Confirmed Overall Response by Investigator"
) %>%
derive_vars_merged(
dataset_add = adsl,
by_vars = exprs(STUDYID, USUBJID),
new_vars = exprs(TRTSDT)
)
)

expect_dfs_equal(
base = expected,
compare = actual,
keys = c("USUBJID", "PARAMCD", "ADT")
)
})

0 comments on commit 246dd9f

Please sign in to comment.