Last modified on 23 July 2009, at 20:05

Statistical Analysis: an Introduction using R/R/Getting help

There are a number of ways to get help in R, and there is also a wide variety of online information. Most installations of R come with a reasonably detailed help file called "An Introduction to R", but this can be rather technical for first-time users of a statistics package. Almost all functions and other objects that are automatically provided in R have a help page which gives intricate details about how to use them. These help pages usually also contain examples, which can be particularly helpful for new users. However, if you don't know the name of what you are looking for, then finding help may not be so easy, although it is possible to search for keywords and concepts that are associated with objects.

Some versions of R give easy access to help files without having to type in commands (for example, versions which provide menu bars usually have a "help" menu, and the Macintosh interface also has a help box in the top right hand corner). However, this functionality can always be accessed by typing in the appropriate commands. You might like to type some or all of the following into an R session (no output is listed here because the result will depend on your R system).

  1. help.start()            #A web-based set of help pages (try the link to "An Introduction to R")
    
  2. help(sqrt)              #Show details of the "sqrt" and similar functions
    
  3. ?sqrt                   #A shortcut to do the same thing
    
  4. example(sqrt)           #run the examples on the bottom of the help page for "sqrt"
    
  5. help.search("maximum")  #gives a list of functions involving the word "maximum", but oddly, "max" is not in there!
    
  6. ### The next line is commented out to reduce internet load. To try it, remove the first # sign.
    
  7. #RSiteSearch("maximum")  #search the R web site for anything to do with "maximum". Probably overkill here!
    
The last but one command illustrates a problem you may come across with using the R help functions. The searching facility for help files is sometimes a bit hit-and-miss. If you can't find exactly what you are looking for, it is often useful to look at the "See also" section of any help files that sound vaguely similar or relevant. In this case, you might probably eventually find the max() function by looking at the "See also" section of the help file for which.max(). Not ideal!.