Displays the argument names and corresponding default values of a function or primitive.
a function (a closure or a primitive).
This function is mainly used interactively to print the argument list
of a function. For programming, consider using
For a closure, a closure with identical formal argument list but an
For a primitive, a closure with the documented usage and
body. Note that some primitives do not make use of named arguments
and match by position rather than name.
NULL in case of a non-function.
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.
str also prints the argument list of a function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
## "regular" (non-primitive) functions "print their arguments" ## (by returning another function with NULL body which you also see): args(ls) args(graphics::plot.default) utils::str(ls) # (just "prints": does not show a NULL) ## You can also pass a string naming a function. args("scan") ## ...but :: package specification doesn't work in this case. tryCatch(args("graphics::plot.default"), error = print) ## As explained above, args() gives a function with empty body: list(is.f = is.function(args(scan)), body = body(args(scan))) ## Primitive functions mostly behave like non-primitive functions. args(c) args(`+`) ## primitive functions without well-defined argument list return NULL: args(`if`)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.