R/check_ex_extrt_exoccur.R
check_ex_extrt_exoccur.Rd
This check looks for EX records where EXTRT is missing but EXOCCUR=Y (or EXOCCUR doesn't exist) and returns a data frame
check_ex_extrt_exoccur(EX)
boolean value if check failed or passed with 'msg' attribute if the test failed
EX <- data.frame(
USUBJID = 1:10,
EXTRT = 1:10,
EXOCCUR = c(rep("Y",5), rep("",5)),
EXSTDTC = "2016-01-01",
EXDOSE = 1:10,
stringsAsFactors=FALSE
)
EX$EXTRT[1]=""
EX$EXTRT[2]="NA"
EX$EXTRT[3]=NA
EX$EXTRT[6]=""
EX$EXTRT[7]="NA"
EX$EXTRT[8]=NA
check_ex_extrt_exoccur(EX)
#> [1] FALSE
#> attr(,"msg")
#> [1] "Patients with Missing EXTRT where EXOCCUR=Y"
#> attr(,"data")
#> USUBJID EXSTDTC EXTRT EXOCCUR EXDOSE
#> 1 1 2016-01-01 Y 1
#> 2 2 2016-01-01 NA Y 2
#> 3 3 2016-01-01 <NA> Y 3
EX$EXOCCUR=NULL
check_ex_extrt_exoccur(EX)
#> [1] FALSE
#> attr(,"msg")
#> [1] "Patients with Missing EXTRT. "
#> attr(,"data")
#> USUBJID EXSTDTC EXTRT EXDOSE
#> 1 1 2016-01-01 1
#> 2 2 2016-01-01 NA 2
#> 3 3 2016-01-01 <NA> 3
#> 4 6 2016-01-01 6
#> 5 7 2016-01-01 NA 7
#> 6 8 2016-01-01 <NA> 8