These predicates check for a given type and whether the vector is "scalar", that is, of length 1.
In addition to the length check, is_string() and is_bool()
return FALSE if their input is missing. This is useful for
type-checking arguments, when your function expects a single string
or a single TRUE or FALSE.
is_scalar_list(x) is_scalar_atomic(x) is_scalar_vector(x) is_scalar_integer(x) is_scalar_double(x) is_scalar_character(x, encoding = NULL) is_scalar_logical(x) is_scalar_raw(x) is_string(x, string = NULL) is_scalar_bytes(x) is_bool(x)
| x | object to be tested. |
|---|---|
| encoding | Defunct as of rlang 0.4.0. |
| string | A string to compare to |