Print the reformatted usage of a function. The arguments of the function are
searched by argsAnywhere, so the function can be either
exported or non-exported in a package. S3 methods will be marked.
usage(FUN, width = getOption("width"), tidy = TRUE, output = TRUE, indent.by.FUN = FALSE, fail = c("warn", "stop", "none"))
| FUN | the function name |
|---|---|
| width | the width of output |
| tidy | whether to reformat the usage code |
| output | whether to write the output to the console (via
|
| indent.by.FUN | whether to indent subsequent lines by the width of the function name (see “Details”) |
| fail | a character string that determines whether to generate a warning,
stop, or do neither, if the width constraint is unfulfillable (default is
|
The R code for the usage is returned as a character string (invisibly).
Line breaks in the output occur between arguments. In particular, default values of arguments will not be split across lines.
When indent.by.FUN is FALSE, indentation is set by the option
getOption("formatR.indent", 4L), the default value of the
indent argument of tidy_source.
#> var(x, y = NULL, na.rm = FALSE, use)usage(plot)#> plot(x, y, ...)usage(plot.default) # default method#> ## Default S3 method: #> plot(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, ...)usage("plot.lm") # on the 'lm' class#> Warning: Could not fit all lines to width 80 (with indent 4): #> (179) " caption = list("Residuals vs Fitted", "Normal Q-Q", "Scale-Location", "Cook's distance", "Residuals vs Leverage", expression("Cook's dist vs Leverage " * h[ii]/(1 - h[ii])))," #> (104) " panel = if (add.smooth) function(x, y, ...) panel.smooth(x, y, iter = iter.smooth, ...) else points,"#> ## S3 method for class 'lm' #> plot(x, which = c(1, 2, 3, 5), #> caption = list("Residuals vs Fitted", "Normal Q-Q", "Scale-Location", "Cook's distance", "Residuals vs Leverage", expression("Cook's dist vs Leverage " * h[ii]/(1 - h[ii]))), #> panel = if (add.smooth) function(x, y, ...) panel.smooth(x, y, iter = iter.smooth, ...) else points, #> sub.caption = NULL, main = "", #> ask = prod(par("mfcol")) < length(which) && dev.interactive(), ..., #> id.n = 3, labels.id = names(residuals(x)), cex.id = 0.75, qqline = TRUE, #> cook.levels = c(0.5, 1), add.smooth = getOption("add.smooth"), #> iter.smooth = if (isGlm && binomialLike) 0 else 3, label.pos = c(4, 2), #> cex.caption = 1, cex.oma.main = 1.25)usage(usage)#> usage(FUN, width = getOption("width"), tidy = TRUE, output = TRUE, #> indent.by.FUN = FALSE, fail = c("warn", "stop", "none"))usage(barplot.default, width = 60) # output lines have 60 characters or less#> ## Default S3 method: #> barplot(height, width = 1, space = NULL, names.arg = NULL, #> legend.text = NULL, beside = FALSE, horiz = FALSE, #> density = NULL, angle = 45, col = NULL, #> border = par("fg"), main = NULL, sub = NULL, #> xlab = NULL, ylab = NULL, xlim = NULL, ylim = NULL, #> xpd = TRUE, log = "", axes = TRUE, axisnames = TRUE, #> cex.axis = par("cex.axis"), cex.names = par("cex.axis"), #> inside = TRUE, plot = TRUE, axis.lty = 0, offset = 0, #> add = FALSE, ann = !add && par("ann"), #> args.legend = NULL, ...)# indent by width of 'barplot(' usage(barplot.default, width = 60, indent.by.FUN = TRUE)#> ## Default S3 method: #> barplot(height, width = 1, space = NULL, names.arg = NULL, #> legend.text = NULL, beside = FALSE, horiz = FALSE, #> density = NULL, angle = 45, col = NULL, #> border = par("fg"), main = NULL, sub = NULL, #> xlab = NULL, ylab = NULL, xlim = NULL, ylim = NULL, #> xpd = TRUE, log = "", axes = TRUE, axisnames = TRUE, #> cex.axis = par("cex.axis"), #> cex.names = par("cex.axis"), inside = TRUE, #> plot = TRUE, axis.lty = 0, offset = 0, add = FALSE, #> ann = !add && par("ann"), args.legend = NULL, ...)if (FALSE) { # a warning is raised because the width constraint is unfulfillable usage(barplot.default, width = 30) }