\HeaderA{nargs}{The Number of Arguments to a Function}{nargs}
\keyword{programming}{nargs}
\begin{Description}\relax
When used inside a function body, \code{nargs} returns the number of
arguments supplied to that function, \emph{including} positional
arguments left blank.
\end{Description}
\begin{Usage}
\begin{verbatim}nargs()\end{verbatim}
\end{Usage}
\begin{Details}\relax
The count includes empty (missing) arguments, so that \code{foo(x,{},z)}
will be considered to have three arguments (see \sQuote{Examples}).
This can occur in rather indirect ways, so for example \code{x[]}
might dispatch a call to \code{`[.some\_method`(x, )`} which is
considered to have two arguments.
\end{Details}
\begin{References}\relax
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
\emph{The New S Language}.
Wadsworth \& Brooks/Cole.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{args}{args}}, \code{\LinkA{formals}{formals}} and \code{\LinkA{sys.call}{sys.call}}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
tst <- function(a, b = 3, ...) {nargs()}
tst() # 0
tst(clicketyclack) # 1 (even non-existing)
tst(c1, a2, rr3) # 3

foo <- function(x, y, z, w) {
   cat("call was", deparse(match.call()), "\n")
   nargs()
}
foo()    # 0
foo(,,3) # 3
foo(z=3) # 1, even though this is the same call

nargs()# not really meaningful
\end{ExampleCode}
\end{Examples}

