8 Using Help

RStudio makes it fairly easy to find documentation on most R functions. However, R documentation takes some practice to read.

The help documentation is generally organized so that each function is documented on one page, but often a single page will contain several functions.

Of course, be sure to make use of the other materials published on the SSCC Website. If you are a member of the SSCC, you can also make an appointment with one of the statistical consultants to discuss your issue further.

8.1 RStudio’s Help Pane

The main way to navigate help is to search. You can either search for the name of a specific function (if you already know it), or you can do a keyword search.

The RStudio Help pane is in the lower right of the workspace, tabbed with Files and Plots. It has two search boxes. The box on the upper right is used to find documentation pages, by function or keyword. The box toward the upper left is used to find keywords within the page you are currently looking at.

Let’s use the t.test() function as an example.

If we did not already know the name of the function, we might search by typing in “t-test” in the search box (and hitting the Enter key). This brings up a list of documentation pages, including help pages. Scanning the list, we see stats::t.test Student's t-Test (stats is the name of a package, but more on packages later). From here we can click on the link and go to the documentation page.

Alternatively, if we know the function name, we can type “t.test” directly in the search box. As we type, we see a list of possible functions, and we can click on the one we want at any time.

An even quicker way of accessing the help page for a function of which we know the name is to enter ?t.test or help(t.test) in the Console.

8.2 Reading a Help Page

A single help page many document more than one function, and a function may work with several types of arguments (methods). This means that not everything documented on a given page is relevant to the task at hand: a big part of reading help is figuring out which details matter, and which ones do not.

The basic elements of a help page are always the same:

  • Description: a brief description
  • Usage: a syntax diagram, showing argument names and default values
  • Arguments: a more detailed description of the argument options
  • Value: the kind of data returned by the function

Most help pages also include:

  • Details: some usage or arguments may require more detailed explanation
  • See Also: related functions
  • Examples: working examples that you can try

Once we have the t.test() help page open, we can use the second search box at the top of the Help pane to find information on a specific argument. Search for “var.equal” to find discussions of this argument further down in the Details section.

8.3 Exercises

  1. Look up the help for rpois(). How many arguments does it take?

  2. Look up the help for mtcars, an example dataset. What does the column am mean? What is the source of the data?