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, ...) 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 sometimes I cannot use this workaround. e.g. args(merge.default) does not give the full form as in the help file. 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. Thank you. Regards, Adai
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
you are looking for the arguments of `merge.data.frame' and not `merge.default'. Maybe this function could be helpful: show.args <- function(fun, method=c("default", "all")){ old <- options(warn=(-1)) on.exit(options(old)) method <- match.arg(method) mfun <- methods(fun) if( method=="default" && length(ind <- grep(".default", mfun))>0 ) args(mfun[ind]) else{ res <- lapply(mfun, args); names(res) <- as.character(mfun); res} } ############ show.args(rep) show.args(plot) show.args(seq, "a") show.args(merge, "a") Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/16/336899 Fax: +32/16/337015 Web: http://www.med.kuleuven.ac.be/biostat/ http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm ----- Original Message ----- From: "Adaikalavan Ramasamy" <ramasamy at cancer.org.uk> To: "R-help" <r-help at stat.math.ethz.ch> Sent: Friday, February 25, 2005 1:14 PM Subject: [R] display full form in args> 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, ...) > > > 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 sometimes I cannot use this workaround. e.g. args(merge.default) > does not give the full form as in the help file. > > > 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. > > Thank you. > > Regards, Adai > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >