Examples for 'base::args'


Argument List of a Function

Aliases: args

Keywords: documentation

### ** Examples

## "regular" (non-primitive) functions "print their arguments"
## (by returning another function with NULL body which you also see):
args(ls)
function (name, pos = -1L, envir = as.environment(pos), all.names = FALSE, 
    pattern, sorted = TRUE) 
NULL
args(graphics::plot.default)
function (x, y = NULL, type = "p", xlim = NULL, ylim = NULL, 
    log = "", main = NULL, sub = NULL, xlab = NULL, ylab = NULL, 
    ann = par("ann"), axes = TRUE, frame.plot = axes, panel.first = NULL, 
    panel.last = NULL, asp = NA, xgap.axis = NA, ygap.axis = NA, 
    ...) 
NULL
utils::str(ls) # (just "prints": does not show a NULL)
function (name, pos = -1L, envir = as.environment(pos), all.names = FALSE, 
    pattern, sorted = TRUE)  
## You can also pass a string naming a function.
args("scan")
function (file = "", what = double(), nmax = -1L, n = -1L, sep = "", 
    quote = if (identical(sep, "\n")) "" else "'\"", dec = ".", 
    skip = 0L, nlines = 0L, na.strings = "NA", flush = FALSE, 
    fill = FALSE, strip.white = FALSE, quiet = FALSE, blank.lines.skip = TRUE, 
    multi.line = TRUE, comment.char = "", allowEscapes = FALSE, 
    fileEncoding = "", encoding = "unknown", text, skipNul = FALSE) 
NULL
## ...but :: package specification doesn't work in this case.
tryCatch(args("graphics::plot.default"), error = print)
<simpleError in args("graphics::plot.default"): could not find function "graphics::plot.default">
## As explained above, args() gives a function with empty body:
list(is.f = is.function(args(scan)), body = body(args(scan)))
$is.f
[1] TRUE

$body
NULL
## Primitive functions mostly behave like non-primitive functions.
args(c)
function (...) 
NULL
args(`+`)
function (e1, e2) 
NULL
## primitive functions without well-defined argument list return NULL:
args(`if`)
NULL

[Package base version 4.2.3 Index]