bf_decode {bitfield} | R Documentation |
Decode (unpack) a bitfield
Description
This function takes an integer bitfield and the registry used to build it upstream to decode it into bit representation and thereby unpack the data stored in the bitfield.
Usage
bf_decode(x, registry, flags = NULL, sep = NULL, verbose = TRUE)
Arguments
x |
|
registry |
|
flags |
|
sep |
|
verbose |
|
Value
data.frame with the binary values of flags in the registry in columns.
Examples
# build registry
reg <- bf_map(protocol = "na", data = bf_tbl, x = commodity)
reg <- bf_map(protocol = "matches", data = bf_tbl, x = commodity, set = c("soybean", "maize"),
registry = reg)
reg
# encode the flags into a bitfield
field <- bf_encode(registry = reg)
field
# decode (somewhere downstream)
flags <- bf_decode(x = field, registry = reg, sep = "-")
flags
# more reader friendly
cbind(bf_tbl, bf_decode(x = field, registry = reg, verbose = FALSE))
[Package bitfield version 0.6.1 Index]