| are_fct_ish | R Documentation |
are_fct_ish() is a vectorized predicate function that checks
whether each element of its input can be safely coerced to a factor.
is_fct_ish() is a scalar predicate function that checks if all elements
of its input can be safely coerced to a factor.
are_fct_ish(x, ..., levels = NULL, to_na = character())
is_fct_ish(x, ...)
## Default S3 method:
are_fct_ish(x, ..., levels = NULL, to_na = character(), depth = 1)
x |
The object to check. |
... |
Arguments passed to methods. |
levels |
|
to_na |
|
depth |
|
are_fct_ish() returns a logical vector with the same length as the
input. is_fct_ish() returns a length-1 logical (TRUE or FALSE) for
the entire vector.
# When `levels` is `NULL`, atomic vectors are fct_ish, but nested lists are not.
are_fct_ish(c("a", 1, NA))
is_fct_ish(c("a", 1, NA))
are_fct_ish(list("a", list("b", "c")))
is_fct_ish(list("a", list("b", "c")))
# When `levels` is specified, values must be in `levels` or `to_na`.
are_fct_ish(c("a", "b", "c"), levels = c("a", "b"))
is_fct_ish(c("a", "b", "c"), levels = c("a", "b"))
# The `to_na` argument allows some values to be treated as `NA`.
are_fct_ish(c("a", "b", "z"), levels = c("a", "b"), to_na = "z")
is_fct_ish(c("a", "b", "z"), levels = c("a", "b"), to_na = "z")
# Factors are also checked against the specified levels.
are_fct_ish(factor(c("a", "b", "c")), levels = c("a", "b"))
is_fct_ish(factor(c("a", "b", "c")), levels = c("a", "b"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.