[R] Get a list of installed commands

David Winsemius dwinsemius at comcast.net
Sun Jun 13 22:25:25 CEST 2010


On Jun 13, 2010, at 3:44 PM, Henrique Dallazuanna wrote:

> Try this:
>
> sapply(installed.packages()[,1], function(x)try(ls(asNamespace(x))))

You could clean that up a bit with:

funlist <- sapply(installed.packages()[,1],  
function(x)try(ls(asNamespace(x))))

function.list <- fun.list[lapply(fun.list, length) >1]  # removes all  
entries for the package with no namespace.

I was left wondering if the speed characteristics of an implementation  
that needed to search against 32K names might be a bit slow?

 > length(function.list)
[1] 211  # number of installed packages on my machine with namespaces
 > sum(unlist(lapply(function.list, length)))
[1] 31960   # number of function names


You might want to limit your search to base R packages minus  
"datasets" ( from R-FAQ listing):

http://cran.r-project.org/doc/FAQ/R-FAQ.html#Add_002don-packages-from-CRAN

  core.pkgs <- c("base", "grDevices", "graphics", "grid", "methods",  
"splines", "stats", "stats4", "tcltk", "tools", "utils")
core.fun.list <- sapply(core.pkgs, function(x) try(ls(asNamespace(x))))
sum(unlist(lapply(core.fun.list[lapply(core.fun.list, length) >1],  
length)))
[1] 4036

-- 
David.

>
> On Sun, Jun 13, 2010 at 9:30 AM, Data Monkey <coco.datamonkey at gmail.com 
> >wrote:
>
>> Thanks Joris. Very helpful.
>>
>> I had thought of that, just curious to see if it was possible to  
>> get a
>> fresh list in R.
>> After reading your email I think perhaps my wording was a bit  
>> loose. I
>> meant commands in the pre-installed packages.
>> So basically, "out of the box" what commands will R recognize.
>>
>> I had found the full reference manual for R online and parsed the  
>> table of
>> contents into a nice XML file I could use as a possible solution.
>> However, your attached file looks a bit more complete (haven't  
>> really given
>> much thought to the reason yet). Thanks again for sending it.
>>
>> I'm using Coda on OS X, which is really designed for Web dev, but I  
>> like it
>> so much I've added support for Stata and now want R. It's got  
>> Terminal
>> bult-in, so I can invoke R through there.
>> Anyway, my ultimate goal is to not only get syntax highlighting,  
>> but also
>> autocompletion. If possible in the prediction, also get the method  
>> (where
>> applicable) signature. Coda allows all this.
>> I use this a lot when coding in PHP in Coda and C# in Visual Studio  
>> - I
>> think Microsoft call it Intellisense or something.
>>
>> Cheers for the help.
>>
>> On 13/06/2010, at 9:47 PM, Joris Meys wrote:
>>
>>> Hi,
>>>
>>> Take a look at any of the R-editors, like Tinn-R, Emacs-ESS, Eclipse
>>> with StatET,... They contain lists you can use. Also the listings
>>> package of LaTeX contains a wordlist for R.
>>>
>>> Getting all installed commands out of R is not doable with a single
>>> command as far as I know. R works completely different than Stata; R
>>> is a fullblown programming language, not a statistical program.  
>>> Try to
>>> find a list of all installed Perl commands for example...
>>>
>>> Attached is the recognition file of Tinn-R. Reserved 1 are special
>>> keywords, Reserved 2 is a list of the most commonly used commands in
>>> the pre-installed packages, and Reserved 3 is a list of common
>>> parameters of those functions. It's submitted with Tinn-R under the
>>> GNU license, so keep that in mind when using it.
>>>
>>> But instead of re-inventing the wheel and constructing your own
>>> editor, you could take a look at one of those mentioned above. On
>>> Windows, I recommend Tinn-R for daily scripting, and Eclipse for
>>> developing packages and the likes. Both offer the advantage of  
>>> direct
>>> communication with the R console.
>>>
>>> Cheers
>>> Joris
>>>
>>> On Sun, Jun 13, 2010 at 9:31 AM, Data Monkey <coco.datamonkey at gmail.com 
>>> >
>> wrote:
>>>> I'm pretty new to R, but have experience with other languages,  
>>>> both OO
>> and scripting.
>>>>
>>>> I'm trying to add support for R to my text editor of choice and  
>>>> to do
>> this I need a list of installed commands I can markup with XML.
>>>> I'd then simply feed in the marked up list into my text editor's  
>>>> library
>> and I'm off.
>>>>
>>>> I've done this in Stata before using the following command:
>>>> getcmds using "~/Desktop/StataCommands.txt"
>>>>
>>>> Does anyone know of a way to do this in R?
>>>>
>>>> Any pointers much appreciated.
>>>>
>>>> Thanks!
>>>>
>>>> ______________________________________________
>>>> 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.
>>>>
>>>
>>>
>>>
>>> --
>>> Joris Meys
>>> Statistical consultant
>>>
>>> Ghent University
>>> Faculty of Bioscience Engineering
>>> Department of Applied mathematics, biometrics and process control
>>>
>>> tel : +32 9 264 59 87
>>> Joris.Meys at Ugent.be
>>> -------------------------------
>>> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
>>> <Tinn-R_recognized words.r>
>>
>> ______________________________________________
>> 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.
>>
>
>
>
> -- 
> Henrique Dallazuanna
> Curitiba-Paraná-Brasil
> 25° 25' 40" S 49° 16' 22" O
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list