Message-ID: <m2tzzznwgl.fsf@ziti.local>
Date: 2006-12-14T00:38:02Z
From: Seth Falcon
Subject: A possible improvement to apropos
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)
}
}
x
}