check_numeric: Checks a set of variables can be coerced to numeric and...

View source: R/params_check_types.R

check_numericR Documentation

Checks a set of variables can be coerced to numeric and coerces them

Description

N.B. This only works for the specific environment (to prevent weird side effects)

Usage

check_numeric(
  ...,
  .message = "`{param}` is non-numeric ({err}).",
  .env = rlang::caller_env()
)

Arguments

...

a list of symbols

.message

a glue specification containing {param} as the name of the parameter and {err} the cause of the error

.env

the environment to check (defaults to calling environment)

Value

nothing. called for side effects. throws error if not all variables can be coerced.

Examples

a = c(1:4L)
b = c("1",NA,"3.3")
f = NULL
g = NA
check_numeric(a,b,f,g)

c = c("dfsfs")
try(check_numeric(c,d, mean))

interfacer documentation built on April 4, 2025, 6:13 a.m.