7  Getting help for R

Author

Jarad Niemi

7.1 Learning R

7.1.1 learnr

The Tutorial tab in RStudio is powered by the learnr package. Since it is built by RStudio it will provide an introduce to the tidyverse approach to data science. Click on the “Install learnr package’ in the RStudio Tutorial tab or run the code below.

install.packages("swirl")

7.1.2 swirl

To learn R, you may want to try the swirl package. To install, use

install.packages("swirl")

After installation, use the following to get started

library("swirl")
swirl()

Also, the R 4 Data Science (R4DS) and R4DS (2e) book is extremely helpful.

7.2 General help

As you work with R, there will be many times when you need to get help.

My basic approach is

  1. Use the help contained within R.
  2. Perform an internet search for an answer.
  3. Find somebody else who knows.

In all cases, knowing the R keywords, e.g. a function name, will be extremely helpful.

7.3 Help within R I

If you know the function name, then you can use ?<function>, e.g.

?mean

The structure of help is

  • Description: quick description of what the function does
  • Usage: the arguments, their order, and default values (if any)
  • Arguments: more thorough description about the arguments
  • Value: what the funtion returns
  • See Also: similar functions
  • Examples: examples of how to use the function

7.4 Help within R II

If you cannot remember the function name, then you can use help.search("<something>"), e.g.

help.search("mean")

Depending on how many packages you have installed, you will find a lot or a little here.

7.5 Internet search for R help

I google for <something> R, e.g. 

calculate mean R

Some useful sites are

7.6 Getting help on ggplot2

Although the general R help can still be used, e.g. 

?ggplot
?geom_point

It is much more helpful to google for an answer

geom_point 
ggplot2 line colors

The top hits will all have the code along with what the code produces.

7.7 Helpful sites

These sites all provide code. The first two also provide the plots that are produced.