Convert a flag specification into actual flag values
bf_flag(registry, flag = NULL)
registry(1)
an already defined bitfield
registry.
character(1)
name of the flag to build.
vector of the flag values.
This function extracts the flag specification, including its test to call it on the data from which the flag shall be created.
reg <- bf_registry(name = "testBF", description = "test bitfield")
reg <- bf_map(protocol = "na", data = bf_tbl, registry = reg,
x = year)
str(reg@flags)
#> List of 1
#> $ na_year:List of 4
#> ..$ comment : 'glue' chr "'year' contains NA-values."
#> ..$ wasDerivedFrom : chr "bf_tbl"
#> ..$ wasGeneratedBy :List of 6
#> .. ..$ useTest : chr "na_1.0.0"
#> .. ..$ withArguments : Named chr "x = year"
#> .. .. ..- attr(*, "names")= chr "x"
#> .. ..$ substituteValue: NULL
#> .. ..$ extractLevels :'data.frame': 2 obs. of 2 variables:
#> .. .. ..$ id : int [1:2] 0 1
#> .. .. ..$ label: logi [1:2] FALSE TRUE
#> .. ..$ encodeAsBinary :List of 4
#> .. .. ..$ sign : int 0
#> .. .. ..$ exponent : int 0
#> .. .. ..$ significand: int 1
#> .. .. ..$ bias : int 0
#> .. ..$ assignPosition : int [1:2] 1 1
#> ..$ wasAssociatedWith: chr "pkrvmsl9tci6h6u_runner"
bf_flag(registry = reg, flag = "na_year")
#> [1] FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE