1.4 Documentation and Help

1.4.1 Built-in Documentation and Help

You can learn more about how a function works by typing in the Console:

  • ?, for example ?sum or
  • help(), for example help(sum).

A help page will appear (by default in the lower right panel in Rstudio) with basic information about the function.

You can also access these help pages using the search box in the toolbar of the Rstudio Help pane, and search within a help page using the search box below the toolbar.

The typical built-in help page is structured as follows:

  • At the top, you can see the package that contains this function, here: sum{base} indicates that the function sum is in the base package
  • Description provides a short explanation
  • Usage shows the syntax for calling the function; if an argument is listed here with a value, that value is the default if you don’t explicitly include the argument, here: na.rm = FALSE
  • Arguments lists the features of the function you can control
  • Details provides more information on how the function operates
  • Value explains what the function outputs
  • See Also lists related functions
  • Examples shows how to use the function in practice

If you do not know the name of the function you need help with, you can search all of R’s documentation with ?? in the Console, for example ??"bar plot". Note that you may need to use quotes if your search includes a space or any special characters.

Finding what you need through the built-in help can be hard sometimes, and the documentation (even when you do find it) can sometimes be difficult to interpret, so if you can’t find what you need here, there are LOTS of online alternatives. You can find answers to questions like “how do I …”, as well as more in-depth introductions to R and advanced training materials.

1.4.3 Online Guides for R

There are many, but our favorite these days is R For Data Science by Garrett Grolemund and Hadley Wickham (also known as R4DS). There is a physical book you can order, but the online gitbook is free, and updated in between new published versions.

1.4.4 Online Cheatsheets

Online cheatsheets for base R and some R packages are becoming more common. Here are some that you might find useful:

Base R cheatsheet

Rstudio cheatsheet collection
Datacamp cheatsheet collection