2.5 Getting help
This book is intended as a relatively brief introduction to R and as such you will soon be using functions and packages that go beyond this scope of this introductory text. Fortunately, one of the strengths of R is its comprehensive and easily accessible help system and wealth of online resources where you can obtain further information.
2.5.1 R help
To access R’s built-in help facility to get information on any function simply use the
help() function. For example, to open the help page our friend the
or you can use the equivalent shortcut
the help page is displayed in the ‘Help’ tab in the Files pane (usually in the bottom right of RStudio)
Admittedly the help files can seem anything but helpful when you first start using R. This is probably because they’re written in a very concise manner and the language used is often quite technical and full of jargon. Having said that, you do get used to this and will over time even come to appreciate a certain beauty in their brevity (honest!). One of the great things about the help files is that they all have a very similar structure regardless of the function. This makes it easy to navigate through the file to find exactly what you need.
The first line of the help document contains information such as the name of the function and the package where the function can be found. There are also other headings that provide more specific information such as
Description: gives a brief description of the function and what it does.
Usage: gives the name of the arguments associated with the function and possible default values.
Arguments: provides more detail regarding each argument and what they do.
Details: gives further details of the function if required.
Value: if applicable, gives the type and structure of the object returned by the function or the operator.
See Also: provides information on other help pages with similar or related content.
Examples: gives some examples of using the function. These are really helpful, all you need to do is copy and paste them into the console to see what happens. You can also access examples at any time by using the
help() function is useful if you know the name of the function. If you’re not sure of the name, but can remember a key word then you can search R’s help system using the
or you can use the equivalent shortcut
The results of the search will be displayed in RStudio under the ‘Help’ tab as before. The
help.search() function searches through the help documentation, code demonstrations and package vignettes and displays the results as clickable links for further exploration.
Another useful function is
apropos(). This function can be used to list all functions containing a specified character string. For example, to find all functions with
mean in their name
apropos("mean") ##  ".colMeans" ".rowMeans" "colMeans" "kmeans" ##  "mean" "mean_temp" "mean.Date" "mean.default" ##  "mean.difftime" "mean.POSIXct" "mean.POSIXlt" "rowMeans" ##  "vec_mean" "weighted.mean"
You can then bring up the help file for the relevant function.
An extremely useful function is
RSiteSearch() which enables you to search for keywords and phrases in function help pages and vignettes for all CRAN packages, and in CRAN task views. This function allows you to access the https://www.r-project.org/search.html search engine directly from the Console with the results displayed in your web browser
2.5.2 Other sources of help
There really has never been a better time to start learning R. There are a plethora of freely available online resources ranging from whole courses to subject specific tutorials and mailing lists. There are also plenty of paid for options if that’s your thing but unless you’ve money to burn there really is no need to part with your hard earned cash. Some resources we have found helpful are listed below.
General R resources
- R-Project: User contributed documentation
- The R Journal: Journal of the R project for statistical computing
- Swirl: An R package that teaches you R from within R
- RStudio’s printable cheatsheets
- Rseek A custom Google search for R-related sites
Google it!: Try Googling any error messages you get. It’s not cheating and everyone does it! You’ll be surprised how many other people have probably had the same problem and solved it.
Stack Overflow: There are many thousands of questions relevant to R on Stack Overflow. Here are the most popular ones, ranked by vote. Make sure you search for similar questions before asking your own, and make sure you include a reproducible example to get the most useful advice. A reproducible example is a minimal example that lets others who are trying to help you to see the error themselves.
R markdown resources
- Basic markdown and R markdown reference
- A good markdown reference
- A good 10-minute markdown tutorial
- RStudio’s R markdown cheatsheet
- R markdown reference sheet
- The R markdown documentation including a getting started guide, a gallery of demos, and several articles for more advanced usage.
- The knitr website has lots of useful reference material about how knitr works.
Git and GitHub resources
- Happy Git: Great resource for using Git and GitHub
- Version control with RStudio: RStudio document for using version control
- Using Git from RStudio: Good 10 minute guide
- The R Class: In depth guide to using Git and GitHub with RStudio