Re: [Rd] A possible improvement to apropos

From: stefano iacus <jago_at_mclink.it>
Date: Thu 14 Dec 2006 - 11:56:49 GMT

I would second Seth here, because the search is case insensitive but results are not.
This is not strictly related to the language. For example, on my shell, the last entries of

apropos system

are

xload(1)                 - system load average display for X
xlogo(1)                 - X Window System logo
xman(1)                  - Manual page display program for the X  
Window System

which I find a reasonable result.

stefano

On 14/dic/06, at 17:45, Martin Maechler wrote:

> Hi Seth,
>
>>>>>> "Seth" == Seth Falcon <sfalcon@fhcrc.org>
>>>>>> on Wed, 13 Dec 2006 16:38:02 -0800 writes:
>
> Seth> Hello all, I've had the following apropos alternative
> Seth> in my ~/.Rprofile for some time, and have found it
> Seth> more useful than the current version. Basically, my
> Seth> version ignores case when searching.
>
> Seth> If others find this useful, perhaps apropos could be
> Seth> suitably patched (and I'd be willing to create such a
> Seth> patch).
>
> Could you live with typing 'i=T' (i.e. ignore.case=TRUE)?
>
> In principle, I'd like to keep the default as ignore.case=FALSE,
> since we'd really should teach the users that R
> *is* case sensitive.
> Ignoring case is the exception in the S/R/C world, not the rule
>
> I have a patch ready which implements your suggestion
> (but not quite with the code below), but as said, not as
> default.
>
> Martin
>
> Seth> + seth
>
> 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
>>> }
>
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri Dec 15 14:22:49 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 Fri 15 Dec 2006 - 07:31:02 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.