How to Search the Web for Help with R
Sometimes the built-in R Help simply doesn’t give you that moment of inspiration to solve your problem. When this happens, it’s time to tap into the information available on the web.
You can search the Internet directly from your R console, by using the RSiteSearch() function. This function enables you to search for keywords in the R documentation, as well as the R Help mailing list archives. RSiteSearch() takes your search term and passes it to the search engine. Then you can view the search results in your web browser.
For example, to use RSiteSearch() to search for the term cluster analysis, use the following:
> RSiteSearch("cluster analysis")
Another way of searching the web directly from your console is to use the add-on package called sos and the search function findFn(). This function is a wrapper around RSiteSearch() that combines all the RSiteSearch() results into tabular form on a single page, which may make the results easier to digest.
To use findFn, you first have to install the sos package:
Then you load the package using library(sos). Finally, you use findFn(“cluster”):
> library(sos) > findFn("cluster") found 2311 matches; retrieving 20 pages, 400 matches. 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
This opens a new tab in your favorite web browser with the results in an easy-to-read table. Each row of the table contains a function, the name of the package, and a helpful description and link to the Help page for that function.
If you’re trying to search for R topics in your favorite search engine, you may find that the results tend to be unrelated to the programming language. One way of improving the accuracy of your search results is to enclose the R in square brackets.
For example, to search for the topic of regression in R, use [R] regression as your search term. This technique seems to work because the R mailing lists tend to have [R] in the topic for each message. In addition, on the Stack Overflow website, questions that are related to R are tagged with [r].
In addition to your favorite search engine, you also can use the dedicated R search siteto search through R functions, vignettes, and the R Help mailing lists. Or you can use the rseek search engine, which is dedicated to R and will search first through all R-related websites for an answer.