pop_rules.RdChecks a rules table mapping a flag name to a condition and returns it as an
admiralease_rules object. Nothing about SAFFL, ITTFL, EFFFL or any
other flag is hardcoded: the flags are whatever the table says they are.
pop_rules(x)An admiralease_rules object: a tibble::tibble with FLAG,
CONDITION, LABEL and a print() method.
FLAGName of the variable to create, e.g. "SAFFL".
CONDITIONAn R expression, as text, evaluated against the data and
returning a logical vector, e.g. "!is.na(TRTSDT)".
LABELOptional. Attached to the created column as its label
attribute, which xportr writes to the transport file.
Rules are applied top to bottom and each flag is visible to the rules below
it, so "SAFFL == \"Y\" & !is.na(BASEEFF)" is a legal condition once SAFFL
has been defined earlier in the table.
rules <- utils::read.csv(
system.file("extdata", "pop_rules.csv", package = "admiralease")
)
pop_rules(rules)
#>
#> ── Population flag rules ──
#>
#> ℹ 5 flags, applied in order.
#> • RANDFL = `!is.na(RANDDT)`
#> • SAFFL = `!is.na(TRTSDT)`
#> • ITTFL = `RANDFL == "Y" & TRT01P != "Screen Failure"`
#> • EFFFL = `SAFFL == "Y" & !is.na(BASEEFF)`
#> • COMPLFL = `EOSSTT == "COMPLETED"`