EVOLUTION-MANAGER
Edit File: nargs.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: The Number of Arguments to a Function</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for nargs {base}"><tr><td>nargs {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>The Number of Arguments to a Function</h2> <h3>Description</h3> <p>When used inside a function body, <code>nargs</code> returns the number of arguments supplied to that function, <em>including</em> positional arguments left blank. </p> <h3>Usage</h3> <pre>nargs()</pre> <h3>Details</h3> <p>The count includes empty (missing) arguments, so that <code>foo(x,,z)</code> will be considered to have three arguments (see ‘Examples’). This can occur in rather indirect ways, so for example <code>x[]</code> might dispatch a call to <code>`[.some_method`(x, )</code> which is considered to have two arguments. </p> <p>This is a <a href="Primitive.html">primitive</a> function. </p> <h3>References</h3> <p>Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) <em>The New S Language</em>. Wadsworth & Brooks/Cole. </p> <h3>See Also</h3> <p><code><a href="args.html">args</a></code>, <code><a href="formals.html">formals</a></code> and <code><a href="sys.parent.html">sys.call</a></code>. </p> <h3>Examples</h3> <pre> 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", sep = "") nargs() } foo() # 0 foo(, , 3) # 3 foo(z = 3) # 1, even though this is the same call nargs() # not really meaningful </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>