Build a bit flag by checking for the type
bf_type(
x,
test,
type = NULL,
coerce = FALSE,
pos = NULL,
na.val = NULL,
description = NULL,
registry = NULL
)
data.frame(1)
the table that contains
test
.
character(1)
the column in x
for which
the type is identified.
character(1)
the for which to check, possible
values are "integer"
, "numeric"
, "character"
or
"logical"
.
logical(1)
whether or not to carry out a more
aggressive test, where the values are coerced to the target type and those
that end up not having NA-values are reported as TRUE
.
integerish(.)
the position(s) in the bitfield that
should be set.
character(1)
optional value that should be
used to substitute NA values in the input data.
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(1)
a bitfield registry that has
been defined with bf_registry
; if it's undefined, an empty
registry will be defined on-the-fly.
an object of class 'registry' with the additional flag defined here.
When coercing values to
integer, they are typically
truncated to the non-decimal part of the value. This function compares the
truncated value to the original value and thus returns TRUE
only
when the original value didn't have a decimals part or when that part was
.0
. It, moreover, returns FALSE
for NA
and
NaN
-values, and also for the special case NA_integer_
, as
this is not supported in many other programs that might provide data for or
use them from this function.
numeric, this function returns
TRUE
for any value that can sensibly be interpreted as numeric, such
as 1L
(an integer) or "1"
(a character), but not "1L"
(a character of an integer) or "one"
(another character). It returns
FALSE
for NA
and NaN
-values, and also for the special
case NA_real_
, as this is not supported in many other programs that
might provide data for or use them from this function.
character,
this function returns FALSE
for Inf and NA
, and also for the
special cases of NA_character_
, as this is not supported in many
other programs that might provide data for or use them from this function.
logical, this function returns TRUE
only for the integer(!)
values 0L
and 1L
. For all other values, including NA
,
this function returns FALSE
.
bf_type(x = tbl_bityield, test = "y", type = "character", coerce = TRUE)
#> width 1
#> flags 1 -
#>
#> pos encoding type col
#> 1 0.0.1/0 type y