R: Check that argument is supplied

check_required {rlang} | R Documentation

## Check that argument is supplied

### Description

Throws an error if `x` is missing.

### Usage

    check_required(x, arg = caller_arg(x), call = caller_env())

### Arguments

`x` | A function argument. Must be a symbol.
`arg` | An argument name as a string. This argument will be mentioned in error messages as the input that is at the origin of a problem.
`call` | The execution environment of a currently running function, e.g. `caller_env()`. The function will be mentioned in error messages as the source of the error. See the `call` argument of `abort()` for more information.

### See Also

`arg_match()`

### Examples

    f <- function(x)  {
      check_required(x)
    }

    # Fails because `x` is not supplied
    try(f())

    # Succeeds
    f(NULL)

[Package rlang version 1.0.2 Index]