hasArg
Check for Argument Names
Description
Checks the current call for an argument corresponding to name.
The name can be one of the formal arguments or a named component
of ....
The behavior on ... distinguishes this function
from !missing(name).
Usage
hasArg(name)
Arguments
name |
an argument to the function in which the call to hasArg occurs.
This can also be a string constant specifying an argument name.
|
Value
returns a logical value.
- If the specified argument is a formal argument to the function where hasArg appears, and
if the current call supplies this argument, hasArg returns TRUE.
- If ... is an argument and the current call contains this argument name as a
named argument, hasArg returns TRUE.
See Also
Examples
ftest <- function(x1, ...) c(hasArg(x1), hasArg(y2))
ftest(1) ## [1] TRUE, FALSE
ftest(1, 2) ## [1] TRUE, FALSE
ftest(y2=2) ## [1] FALSE, TRUE
ftest(y=2) ## [1] FALSE, FALSE (no partial matching on ... args)
ftest(y2=2, x=1) ## [1] TRUE, TRUE
## 'x' actual argument partial matches to x1 before hasArg is called