R/check_dm_dthfl_dthdtc.R
check_dm_dthfl_dthdtc.Rd
This check is bi-directional for consistency of DM.DTHFL and DM.DTHDTC and returns a data frame. Note there is a possible valid scenario for this issue if death date is truly unknown
check_dm_dthfl_dthdtc(DM)
boolean value if check failed or passed with 'msg' attribute if the test failed
DM <- data.frame(
USUBJID = 1:7,
DTHFL = 1:7,
DTHDTC = 1:7
)
DM$DTHFL[1] = ""
DM$DTHDTC[1] = "2020-01-01"
DM$DTHFL[2] = "N"
DM$DTHDTC[2] = "2020-01-01"
DM$DTHFL[3] = "Y"
DM$DTHDTC[3] = "2020-01-01"
DM$DTHFL[4] = "Y"
DM$DTHDTC[4] = ""
DM$DTHFL[5] = "N"
DM$DTHDTC[5] = ""
DM$DTHFL[6] = "Y"
DM$DTHDTC[6] = "2020"
DM$DTHFL[7] = ""
DM$DTHDTC[7] = ""
check_dm_dthfl_dthdtc(DM)
#> [1] FALSE
#> attr(,"msg")
#> [1] "DM has 3 records with inconsistent values of DTHFL and DTHDTC. "
#> attr(,"data")
#> USUBJID DTHFL DTHDTC
#> 1 1 2020-01-01
#> 2 2 N 2020-01-01
#> 3 4 Y
DM$DTHFL <- NULL
DM$DTHDTC <- NULL
check_dm_dthfl_dthdtc(DM)
#> [1] FALSE
#> attr(,"msg")
#> [1] "DM is missing the variables: DTHFL, DTHDTC"