Skip to contents

do.call but without an error for unused arguments

Usage

ignore_unused_args(what, args)

Arguments

what

either a function or a non-empty character string naming the function to be called.

args

a list of arguments to the function call. The names attribute of args gives the argument names.

Value

The result of the (evaluated) function call.

Examples

# works:
DescrTab2:::ignore_unused_args(
  chisq.test,
  list(x = factor(c(1, 0, 1, 1, 1, 0)), y = factor(c(0, 1, 1, 0, 1, 0)), abc = 3)
)
#> Warning: Chi-squared approximation may be incorrect
#> 
#> 	Pearson's Chi-squared test
#> 
#> data:  structure(c(2L, 1L, 2L, 2L, 2L, 1L), levels = c("0", "1"), class = "factor") and structure(c(1L, 2L, 2L, 1L, 2L, 1L), levels = c("0", "1"), class = "factor")
#> X-squared = 0, df = 1, p-value = 1
#> 

# would produce error:
# do.call(chisq.test, list(x=factor(c(1,0,1,1,1,0)), y=factor(c(0,1,1,0,1,0)), abc=3 ) )