[R] searching Jonathan Baron's R Site

Jonathan Baron baron at psych.upenn.edu
Thu Dec 23 16:02:00 CET 2004

First, my site will be down December 27-28 because of a network
upgrade at Penn.  It will also be down at least one day before
that, while I upgrade the operating system.  (And another day
some time in January because of a planned power outage.)

Second, I have replaced the search engine in my R site:

I am now using Namazu instead of HtDig.  The direct link to the
search page is

Namazu has capabilities that HtDig does not have, such as
wildcard searches.  (On the down side, its phrase searching works
fine for two word phrases, but a search for "A B C" will actually
produce something like "A B" or "B C", so it will give you more
than you want.  But HtDig's phrase searching seems completely
broken, so this is actually an improvement.)

The HtDig search engine is still there, but I do not plan to
update it anymore.  And it may stop working completely when I
upgrade from Fedora Core 2 to FC3 (as it almost did after the
last upgrade).

Here is a modification of Andy Liaw's search function.  I think
it works now, but I haven't tested it extensively.  It needs some
documentation.  But I'll wait to do that until I make a few more
changes in the site (in particular, collapsing all the mail
before 2002 into one index - without affecting existing links).

This function runs from within R and opens a web page with the
results of the search.  For example,

RSiteSearch("multiple imputation")


RSiteSearch <- function(string,
                        format="normal", sortby="score", matchesPerPage=10) {
    string <- paste("http://finzi.psych.upenn.edu/cgi-bin/namazu.cgi?query=",
                    gsub(" ", "+", string), sep="")
    mpp <- paste("max=", matchesPerPage, sep="")

    format <- charmatch(format, c("normal", "short"))
    if (format == 0) stop("format must be either normal or short")
    format <- paste("result=", switch(format, "normal", "short"), sep="")

    sortby <- charmatch(sortby, c("score", "date:late", "date:early",
                                  "field:subject:ascending", "field:subject:decending",
                                  "field:from:ascending", "field:from:decending",
                                  "field:size:ascending", "field:size:decending",
                                  "field:uri:ascending", "field:uri:decending",))
    if (sortby == 0) stop("wrong sortby specified")
    sortby <- paste("sort=",
                    switch(sortby, "score", "date:late", "date:early",
                                  "field:subject:ascending", "field:subject:decending",
                                  "field:from:ascending", "field:from:decending",
                                  "field:size:ascending", "field:size:decending",
                                  "field:uri:ascending", "field:uri:decending"),

    res <- ""
    if ("Rhelp02a" %in% restrict) res <- "idxname=Rhelp02a"
    if ("Rhelp01" %in% restrict) res <- paste(res,"idxname=Rhelp01",sep="&")
    if ("Rhelp00" %in% restrict) res <- paste(res,"idxname=Rhelp00",sep="&")
    if ("Rhelpold" %in% restrict) res <- paste(res,"idxname=Rhelpold",sep="&")
    if ("docs" %in% restrict) res <- paste(res,"idxname=docs",sep="&")
    if ("functions" %in% restrict) res <- paste(res,"idxname=functions",sep="&")
    if (res=="") res <- paste("idxname=Rhelp02a&idxname=Rhelp01&idxname=Rhelp00&",
    res <- sub("^&+","",res)

    qstring <- paste(string, mpp, format, sortby, res, sep="&")

Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page: http://www.sas.upenn.edu/~baron

More information about the R-help mailing list