Thorsten Jolitz
2014-Oct-29 13:09 UTC
[R] Ways to get all function signatures of a library?
Hi List, are there ways to get signatures of all functions of a library in a format that is easy to process by a programm (list, xml or so)? The info about function name, return value and arguments (types) is all there in the docs, but more in a human readable format embedded in much extra information. How to extract it without writing a documentation parser or so? I'm pretty sure the functionality exists, but did not find it. Thanks for any hint. -- cheers, Thorsten
Perhaps the ?formals function in R is what you are looking for. Or maybe its (internal C) code. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." Clifford Stoll On Wed, Oct 29, 2014 at 6:09 AM, Thorsten Jolitz <tjolitz at gmail.com> wrote:> > Hi List, > > are there ways to get signatures of all functions of a library in a > format that is easy to process by a programm (list, xml or so)? > > The info about function name, return value and arguments (types) is all > there in the docs, but more in a human readable format embedded in much > extra information. How to extract it without writing a documentation > parser or so? I'm pretty sure the functionality exists, but did not find > it. > > Thanks for any hint. > > -- > cheers, > Thorsten > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Gabor Grothendieck
2014-Oct-29 16:13 UTC
[R] Ways to get all function signatures of a library?
On Wed, Oct 29, 2014 at 9:09 AM, Thorsten Jolitz <tjolitz at gmail.com> wrote:> > Hi List, > > are there ways to get signatures of all functions of a library in a > format that is easy to process by a programm (list, xml or so)? > > The info about function name, return value and arguments (types) is all > there in the docs, but more in a human readable format embedded in much > extra information. How to extract it without writing a documentation > parser or so? I'm pretty sure the functionality exists, but did not find > it. >In general, R functions do not have argument and return types (and don't even have to have names) but maybe this would do: library(lattice) # need this for make.groups # load the package of interest library(zoo) DF <- do.call(make.groups, Map(function(x) names(formals(get(x))), ls("package:zoo"))) rownames(DF) <- NULL giving:> head(DF)data which 1 x as.Date 2 ... as.Date 3 x as.Date.numeric 4 origin as.Date.numeric 5 ... as.Date.numeric 6 x as.Date.ts -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com