Build a bit flag by checking for a range

bf_range(
  x,
  test,
  min = NULL,
  max = NULL,
  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 a range is checked.

min

numeric(1)
the minimum allowed value.

max

numeric(1)
the maximum allowed value.

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

when leaving either min or max at NULL they are set to the minimum or maximum value of test, respectively, thereby carrying out a "less than max" or "greater than min" operation.

Examples

bf_range(x = tbl_bityield, test = "y", min = 50, max = 59, na.val = 0)
#>   width 1
#>   flags 1  -
#> 
#>   pos   encoding type   col
#>   1     0.0.1/0  range  y