Build a bit flag by counting aspects of an entity

bf_length(
  x,
  test,
  dec = NULL,
  fill = TRUE,
  pos = NULL,
  na.val = NULL,
  description = NULL,
  registry = NULL
)

Arguments

x

data.frame(1)
the table that contains test.

test

character(1)
the column in x for which the length is determined.

dec

character(1)
regex-compatible symbol that separates the decimals from the numeric value (such as \. in case the decimal symbol is a ".").

fill

logical(1)
whether the function should consider decimals lengths from 0 through the maximum length in x[[test]], or whether it should only document existing decimal lengths.

pos

integerish(.)
the position(s) in the bitfield that should be set.

na.val

character(1)
optional value that should be used to substitute NA values in the input data.

description

character(.)
optional description that should be used instead of the default function-specific description. This description is used in the registry legend, so it should have as many entries as there will be entries per the respective flag in the legend (two for a binary flag, as many as there are cases for a cases flag and one for count or numeric flags).

registry

registry(1)
a bitfield registry that has been defined with bf_registry; if it's undefined, an empty registry will be defined on-the-fly.

Value

an object of class 'registry' with the additional flag defined here.

Details

The console output of various classes shows decimals that are not present or round decimals away that are present, even for ordinary numeric vectors. If a bit flag doesn't seem to coincide with the values you see in the console, double check the values with str.

Determine the number of decimals of coordinates to determine their precision: https://en.wikipedia.org/wiki/Decimal_degrees

Examples

bf_length(x = tbl_bityield, test = "y")
#>   width 3
#>   flags 1  ---
#> 
#>   pos   encoding type    col
#>   1     0.0.3/0  length  y
bf_length(x = tbl_bityield, test = "y", dec = "\\.")
#>   width 1
#>   flags 1  -
#> 
#>   pos   encoding type      col
#>   1     0.1.0/0  decimals  y