Number of Arguments to Function

DESCRIPTION:

Call nargs from a function to count how many arguments were passed in the current call to the function. Or, call nDotArgs to count the number of ... arguments passed.

USAGE:

nargs() 
nDotArgs(...) 

VALUE:

the number of actual arguments (or ... arguments) in the call to the function which calls nargs (or nDotArgs).

SEE ALSO:

EXAMPLES:

myfun <- function(..., a=4) nargs() 
myfun()                 # returns 0 
myfun(1:3,"bear")       # returns 2 
myfun(a=5, 1:3, "bear") # returns 3

myfun <- function(..., a=4) nDotArgs(...)
myfun()                 # returns 0 
myfun(1:3,"bear")       # returns 2 
myfun(a=5, 1:3, "bear") # returns 2 (excludes a)

# Note that both functions are intended to be called
# from other functions, and that their syntax differs:
#      nargs()
#      nDotArgs(...)