Reason 4 Fantastic documentation

  • Accessing the function documentation in RStudio
  • Using auto completion while writing code
  • Finding help in cheat sheets and online

Are you wondering how you should ever remember all of the different R commands and how to use them? Fear not! R and RStudio have a number of ways to make your life easier.

4.1 Accessing function documentation

The Help panel in RStudio gives you direct access to the help files of all R functions that you have installed. You can search in the search box there, or type ?mysterious_function in the console. However, my favorite way to assess the help is to put the cursor on the function name and press F1.13

R’s function documentation, package vignettes and package websites are usually well-written and comprehensive. Having the documentation easily available in RStudio helps to learn the basics quickly and stay in the flow while you code.

Exercise 4.1 Look at the help file for the mean() function, see what other arguments the function accepts. How would you calculate a trimmed mean?

To get the 10% trimmed mean of a numerical vector x, you can run mean(x, trim = 0.1). This will remove 10% of the lowest observations and 10% of the highest observations before calculating the mean. For example:

mean(c(-1000, 2, 2, 2, 2, 2, 2, 2, 2, 20, 1000), trim = .1)
[1] 4

4.2 Auto-completion

If you can’t quite remember the function name, RStudio will try to assist you with its excellent fuzzy auto-completion that suggests functions while you type. Use , , and to select one of the choices.

4.3 Cheat sheets

There are a lot of handy cheat sheets for popular R packages. You can find them in the RStudio menu, if you go to Help ▸ Cheat Sheets.

Exercise 4.2 Have a look at the cheat sheet for the RStudio IDE and find out how to search and replace code in RStudio.

4.4 Finding help online

If you run into a problem or an error message that you can’t figure out yourself, try to Google the problem. Someone else has probably run into a similar problem before. Stack Overflow, RStudio Community, or the R mailing list are full of people asking and answering questions about R. You can also find many blogs with tutorials written by other R users that explain how to do certain things in R. R Bloggers aggregates many of these blogs. Also check out the searchable database of “R Posts you might have missed”

If you can’t find an answer, you are welcome to ask your questions to the R community. Remember that you are asking people to volunteer their time to help you. Thus, make it as easy as possible for them to answer you.

Reproducible examples

A good way to increase your chances for getting help online is to make a reproducible example. Provide an example of the code that produces the problem and make it easy for others to run and understand it. Try to narrow down the problem to its core. Strip away everything that is not relevant.

Quite often, when trying to do that you will stumble across the solution yourself.


  1. Similarly, you can use F2 to access the source code for anything – It is open source, after all!↩︎