test_farg: Test whether function has certain arguments

Description Usage Arguments Examples

Description

Test whether function has certain arguments

Usage

1
test_farg(fun, arg, dots = TRUE)

Arguments

fun

function

arg

characters of function arguments

dots

whether fun's dots (...) counts

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
a <- function(n = 1){}

# Test whether `a` has argument called 'b'
test_farg(a, 'b')

# Test whether `a` has argument called 'b' and 'n'
test_farg(a, c('b', 'n'))

# `a` now has dots
a <- function(n = 1, ...){}

# 'b' could goes to dots and a(b=...) is still valid
test_farg(a, 'b')

# strict match, dots doesn't count
test_farg(a, 'b', dots = FALSE)

dipsaus documentation built on Sept. 6, 2021, 5:08 p.m.