This check looks for missing EXODOSU values for valid doses
check_ex_exdosu(EX)
boolean value if check failed or passed with 'msg' attribute if the test failed
EX <- data.frame(
USUBJID = 1:10,
EXTRT = 1:10,
EXSTDTC = 1:10,
EXDOSE = 1:10,
EXOCCUR = as.character(c(rep("Y",5),rep("N",5))),
EXDOSU = as.character(rep("mg",10))
)
EX$EXDOSU[1] = ""
EX$EXDOSU[2] = "NA"
EX$EXDOSU[3] = NA
check_ex_exdosu(EX)
#> [1] FALSE
#> attr(,"msg")
#> [1] "There are 3 records with missing dose units. "
#> attr(,"data")
#> USUBJID EXTRT EXDOSE EXSTDTC EXDOSU
#> 1 1 1 1 1
#> 2 2 2 2 2 NA
#> 3 3 3 3 3 <NA>
EX$EXSTDTC = NULL
check_ex_exdosu(EX)
#> [1] FALSE
#> attr(,"msg")
#> [1] "EX is missing the variable: EXSTDTC"