Re: [R] listing all functions in R

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
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,
                                               mode="function",
                                               inherits=FALSE)))]
     } 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,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@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
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 https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.