R: Scalar type predicates

scalar-type-predicates {rlang} | R Documentation

## Scalar type predicates

### Description

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`.

### Usage

    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)

### Arguments

`x` | object to be tested.
`encoding` | Defunct as of rlang 0.4.0.
`string` | A string to compare to `x`. If a character vector, returns `TRUE` if at least one element is equal to `x`.

### See Also

type-predicates, bare-type-predicates

[Package rlang version 0.4.1 Index]