Skip to content

Commit b4fa161

Browse files
committed
Add test for print msg for timing variables
1 parent e438c72 commit b4fa161

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# iddoverse 0.9.0
22
* create_participant_table: baseline timing EPOCH == BASELINE then VISITDY == 1, change from any of VISITDY == 1, DY == 1 and EPOCH == BASELINE
33
* prepare_domain: data first, domain second in parameter order to align with tidy principles, changes to downstream functions, examples, documentation, tests and vignette
4+
* prepare_domain: added a print message describing the timing variables used in console
45
* table_variables: data first, domain second in parameter order to align with tidy principles
56
* prepare_domain: default timing changed to HR, DY, STDY, CDSTDY, VISITDY, EPOCH (removed VISIT, VISITNUM, EVLINT, EVLINTX)
67
* hexsticker logo includes package name

R/prepare_domain.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ prepare_domain <- function(data, domain,
6666

6767
event_domains <- c("SA", "HO", "ER", "PO")
6868

69-
# "DS" dealt with unique
69+
# "DS" dealt with uniquely
7070

7171
domain <- str_to_upper(domain)
7272

@@ -76,6 +76,12 @@ prepare_domain <- function(data, domain,
7676

7777
timing_variables <- timing_variables[which(timing_variables %in% names(data))]
7878

79+
if(print_messages == TRUE){
80+
if(domain != "DM"){
81+
print(str_c("The timing variable(s) hierarchy being used in prepare_domain() for the ", domain, " domain are: ", str_flatten(timing_variables, collapse = ", ")))
82+
}
83+
}
84+
7985
if(include_LOC == TRUE & !(str_c(domain, "LOC") %in% names(data))){
8086
rlang::warn(str_c("This dataset does not have a location (", domain, "LOC) variable, yet include_LOC is TRUE"))
8187
include_LOC = FALSE

tests/testthat/test-prepare_domain.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ test_that("check print_messages parameter option", {
221221

222222
expect_output(prepare_domain(sa, "SA", variables_include = c("FEVER"), print_messages = TRUE),
223223
regexp = "Number of rows where values_fn has been used to pick record")
224+
expect_output(prepare_domain(sa, "SA", variables_include = c("FEVER"), print_messages = TRUE),
225+
regexp = "The timing variable")
224226
})
225227

226228
test_that("prepare_domain errors when required STUDYID or USUBJID missing", {

0 commit comments

Comments
 (0)