Check a function has specified arguments

has_args(f, args, exact = FALSE)

f %has_args% args

Arguments

f

a function

args

a character vector of argument names

exact

if TRUE, argument names must match args exactly (order and value); otherwise f just must have at least args in any order

Examples

has_args(mean, "x")
#> [1] TRUE
has_args(mean, "x", exact = TRUE)
#> [1] FALSE

see_if(mean %has_args% "x")
#> [1] TRUE
see_if(mean %has_args% "y")
#> [1] FALSE
#> attr(,"msg")
#> [1] "`%has_args%`(f = mean, args = \"y\") is not TRUE"