[R] Ways to get all function signatures of a library?

Thorsten Jolitz tjolitz at gmail.com
Wed Oct 29 19:48:36 CET 2014


Gabor Grothendieck <ggrothendieck at gmail.com> writes:

> 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:
 
Thats ok, I only need to know about it. Makes calling these functions
even easier.

> 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

Thats a nice solution, thanks a lot! 

-- 
cheers,
Thorsten



More information about the R-help mailing list