[Rd] A possible improvement to apropos

From: Seth Falcon <sfalcon_at_fhcrc.org>
Date: Thu 14 Dec 2006 - 00:38:02 GMT

Hello all,

I've had the following apropos alternative in my ~/.Rprofile for some time, and have found it more useful than the current version. Basically, my version ignores case when searching.

If others find this useful, perhaps apropos could be suitably patched (and I'd be willing to create such a patch).

+ seth

Here is my version of apropos:

APROPOS <- function (what, where = FALSE, mode = "any") {

    if (!is.character(what))
      stop("argument ", sQuote("what"), " must be a character vector")     x <- character(0)
    check.mode <- mode != "any"
    for (i in seq(search())) {

        contents <- ls(pos = i, all.names = TRUE)
        found <- grep(what, contents, ignore.case = TRUE, value = TRUE)
        if (length(found)) {
            if (check.mode) {
                found <- found[sapply(found, function(x) {
                    exists(x, where = i, mode = mode, inherits = FALSE)
            numFound <- length(found)
            x <- c(x, if (where)
                   structure(found, names = rep.int(i, numFound)) else found)


R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu Dec 14 15:09:07 2006

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 Thu 14 Dec 2006 - 10:30:53 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.