Utilizes the BLFL method from the SDTM spec to create a baseline flag: Equal
to "Y" for last record with non-missing --ORRES on or before first dose date
(RFSTDTC); NA otherwise.
Usage
create_BLFL(
tbl,
sort_date,
domain,
grouping_vars = "USUBJID",
RFSTDTC = "RFSTDTC",
compare_date_method = "on or before"
)Arguments
- tbl
a data frame with the variables
USUBJID,[domain]ORRES,RFSTDTC, and to column specified in thesort_dateargument- sort_date
a string, the column name by which to sort records within each
USUBJIDentry before assigning the BLFL value. This is also the date compared againstRFSTDTCto determine the BLFL value. This column should either already have a date class or be a character vector in the format YYYY-MM-DD- domain
a string, the SDTM domain abbreviation
- grouping_vars
a character vector of columns to group by when assigning the BLFL, default is
"USUBJID". The order of this vector matters.- RFSTDTC
a string, the column to use for
RFSTDTC, default is"RFSTDTC"; this columns should either have a date class or a characer class in the YYYY-MM-DD format- compare_date_method
a string, one of
c("on or before", "before")indicating where the baseline measurement should be evaluated on or before the study start date or just before; default is"on or before"
Examples
df <- dplyr::tibble(
USUBJID = c(
rep(1, 3),
rep(2, 3)
),
XXORRES = c(
1, 2, 2,
1, 2, NA
),
XXDTC = as.Date(c(
"2017-02-05", "2017-02-06", "2017-02-07",
"2017-02-05", "2017-02-06", "2017-02-07"
)),
RFSTDTC = as.Date(c(
rep("2017-02-05", 3),
rep("2017-02-07", 3)
))
)
create_BLFL(df, sort_date = "XXDTC", domain = "XX")
#> # A tibble: 6 × 5
#> USUBJID XXORRES XXDTC RFSTDTC XXBLFL
#> <dbl> <dbl> <date> <date> <chr>
#> 1 1 1 2017-02-05 2017-02-05 Y
#> 2 1 2 2017-02-06 2017-02-05 NA
#> 3 1 2 2017-02-07 2017-02-05 NA
#> 4 2 1 2017-02-05 2017-02-07 NA
#> 5 2 2 2017-02-06 2017-02-07 Y
#> 6 2 NA 2017-02-07 2017-02-07 NA
