R/check_ds_dsterm_death_due_to.R
check_ds_dsterm_death_due_to.Rd
This check looks for DS.DSTERM values with missing death reason and returns a data frame (e.g. records where DSTERM = 'DEATH DUE TO')
check_ds_dsterm_death_due_to(DS)
boolean value if check failed or passed with 'msg' attribute if the test failed
DS <- data.frame(
STUDYID = 1,
USUBJID = 1:4,
DSTERM = c("DEATH DUE TO",
"DEATH DUE TO ",
"DEATH DUE TO ADVERSE EVENT",
"DEATH DUE TO UNKNOWN"),
DSDECOD = "DEATH",
DSDTC = "2017-01-01",
DSSTDTC = "2017-01-01",
stringsAsFactors=FALSE
)
check_ds_dsterm_death_due_to(DS)
#> [1] FALSE
#> attr(,"msg")
#> [1] "DS has 2 records with missing death reason. "
#> attr(,"data")
#> USUBJID DSTERM DSDECOD DSDTC DSSTDTC
#> 1 1 DEATH DUE TO DEATH 2017-01-01 2017-01-01
#> 2 2 DEATH DUE TO DEATH 2017-01-01 2017-01-01
DS$DSDECOD <- NULL
check_ds_dsterm_death_due_to(DS)
#> [1] FALSE
#> attr(,"msg")
#> [1] "DS is missing the variable: DSDECOD"