[R] display full form in args

Adaikalavan Ramasamy ramasamy at cancer.org.uk
Fri Feb 25 14:51:05 CET 2005


Dimitris, thank you. This is a useful function. 


On Fri, 2005-02-25 at 14:32 +0100, Dimitris Rizopoulos wrote:
> 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
> > 
> 
>




More information about the R-help mailing list