[R] display full form in args
Prof Brian Ripley
ripley at stats.ox.ac.uk
Fri Feb 25 13:52:41 CET 2005
On Fri, 25 Feb 2005, Adaikalavan Ramasamy wrote:
> Forgive me for I do not fully comprehend the idea of classes and methods
> but I was wondering if someone could help explain why the function args
> () behaves the way it does.
>
> Why does args(cut) show the simplified version instead of the more
> complete one as in help("cut"). This is true for few other functions
> (e.g. plot, rep).
>
> > args(cut)
> function (x, ...)
Adai,
That _is_ the full form: those are formal arguments shared by all methods.
For help(cut) I get
Usage:
cut(x, ...)
which is the same.
> Sometime I can get around this by using the "default" method as in
>
> > args(cut.default)
> function (x, breaks, labels = NULL, include.lowest = FALSE, right =
> TRUE, dig.lab = 3, ...)
but other methods have other args, e.g.
> args(cut.Date)
function (x, breaks, labels = NULL, start.on.monday = TRUE, right = FALSE,
...)
> But sometimes I cannot use this workaround. e.g. args(merge.default)
> does not give the full form as in the help file.
It is the *data frame* method that you are looking at in the help file.
Usage:
merge(x, y, ...)
## Default S3 method:
merge(x, y, ...)
## S3 method for class 'data.frame':
merge(x, y, by = intersect(names(x), names(y)),
by.x = by, by.y = by, all = FALSE, all.x = all, all.y = all,
sort = TRUE, suffixes = c(".x",".y"), ...)
> I find it almost always useful to see the full form. Is there a more
> reliable workaround or do I have to look up the help to be certain.
You can look at the method you want to use. Try not to overlook those
comments in the help files' usage sections.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list