R/check_lb_lbstresc_char.R
check_lb_lbstresc_char.Rd
This check looks for missing numeric standardized finding (LBSTRESN) when original finding (LBORRES) and character standardized finding (LBSTRESC) are not missing and LBORRES/LBSTRESC populated with number beginning with character '>' or '<'
check_lb_lbstresc_char(LB)
boolean value if check failed or passed with 'msg' attribute if the test failed
LB <- data.frame(
USUBJID = c("Patient 1","Patient 2","Patient 3"),
LBTEST = "Test A",
LBDTC = "2017-01-01",
LBORRES = c("5","3","7"),
LBORRESU = rep("mg",3),
LBSTRESC = c("5","3","7"),
LBSTRESN = c(5,3,7),
stringsAsFactors = FALSE
)
check_lb_lbstresc_char(LB)
#> [1] TRUE
LB <- data.frame(
USUBJID = c("Patient 1","Patient 2","Patient 3"),
LBTEST = rep("Test A", 3),
LBDTC = "2017-01-01",
LBORRES = c("5","3","<7"),
LBORRESU = rep("mg",3),
LBSTRESC = c("5","3","<7"),
LBSTRESN = c(5,3,NA),
stringsAsFactors = FALSE
)
check_lb_lbstresc_char(LB)
#> [1] FALSE
#> attr(,"msg")
#> [1] "LBSTRESN missing but LBORRES/LBSTRESC populated with number beginning with character > or < for 1 record(s). "
#> attr(,"data")
#> USUBJID LBTEST LBDTC LBORRES LBORRESU LBSTRESN LBSTRESC
#> 3 Patient 3 Test A 2017-01-01 <7 mg NA <7
LB <- data.frame(
USUBJID = c("Patient 1","Patient 2","Patient 3"),
LBTEST = rep("Test A", 3),
LBDTC = rep("2017-01-01", 3),
LBORRES = c("5","BLQ","<7"),
LBORRESU = rep("mg",3),
LBSTRESC = c("5","BLQ","<7"),
LBSTRESN = c(5,NA,NA),
stringsAsFactors = FALSE
)
check_lb_lbstresc_char(LB)
#> [1] FALSE
#> attr(,"msg")
#> [1] "LBSTRESN missing but LBORRES/LBSTRESC populated with number beginning with character > or < for 1 record(s). "
#> attr(,"data")
#> USUBJID LBTEST LBDTC LBORRES LBORRESU LBSTRESN LBSTRESC
#> 3 Patient 3 Test A 2017-01-01 <7 mg NA <7