assertive.base (version 0.0-7)

call_and_name: Call a function, and give the result names.

Description

Calls a function, and names the result with the first argument.

Usage

call_and_name(fn, x, ...)

Arguments

fn

A function to call. See note below.

x

The first input to fn.

...

Optional additional inputs to fn.

Value

The result of fn(x, ...), with names given by the argument x.

See Also

cause and na.

Examples

Run this code
# NOT RUN {
call_and_name(is.finite, c(1, Inf, NA))

# Make sure that the output is the same size as the input.
# Don't do this:
dont_stop(call_and_name(isTRUE, list(TRUE, FALSE, NA)))
# Do this instead:
call_and_name(
  Vectorize(isTRUE, SIMPLIFY = FALSE),
  list(TRUE, FALSE, NA)
)
# }

Run the code above in your browser using DataCamp Workspace