Re: [R] listing all functions in R

From: Prof Brian Ripley <>
Date: Sat 06 Jan 2007 - 13:48:15 GMT

Could you tell us what you mean by

Here is a reasonable shot:

findfuns <- function(x) {

     if(require(x, character.only=TRUE)) {
        env <- paste("package", x, sep=":")
        nm <- ls(env, all=TRUE)
        nm[unlist(lapply(nm, function(n) exists(n, where=env,
     } else character(0)

pkgs <- dir(.Library)

z <- lapply(pkgs, findfuns)
names(z) <- pkgs

I don't understand your desired format, but

write(sQuote(sort(unique(unlist(z)))), "")

gives a single-column quoted list. It does include internal functions, operators, S3 methods ... so you probably want to edit it.

On Sat, 6 Jan 2007, Gavin Simpson wrote:

> Dear List,
> I'm building an R syntax highlighting file for GeSHi [*] for a website I
> am currently putting together. The syntax file needs a list of keywords
> to highlight. How can I generate a list of all the functions in a base R
> installation?
> Ideally the list would be formatted like this:
> "'fun1', 'fun2', 'fun3'"
> when printed to the screen so I can copy and paste it into the syntax
> file.
> I'm sure this has been asked before, but I stupidly didn't save that
> email and I couldn't come up with a suitable query parameter for
> Jonathan Baron's search site to return results before timing out.
> Thanks in advance,
> Gav

Brian D. Ripley,        
Professor of Applied Statistics,
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Sun Jan 07 01:20:35 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 08 Jan 2007 - 21:30:30 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.