Troubleshoot and Get Help

Learn how to troubleshoot and get help.

One important principle to keep in mind in using R is that we will always have coding errors, serious or minor, such that troubleshooting and getting help is an indispensable part of using R. Knowing where to look for coding errors and where and how to get help is critical and can save one many hours. When a program fails to execute, it is common for a beginner to spend half an hour searching for a major error in their code, only to find that their error was due to a missing comma or parenthesis, a misspelled word, or a mix-up in the upper or lower case.

These occurrences are just too common to ignore. Here we provide information about common coding errors and useful resources for beginners in R.

Common coding errors for beginners

When we create our first programs in R, we will definitely make errors. Learning to debug these errors is part of getting proficient with R. It is common to make programming errors in R, just like in any other software environment. The best suggestion is: Don’t Panic!

It is useful to remember that there is more often than not a very simple reason for why we get an error message. R’s error messages are not always clear or useful. We can always help ourselves by checking the following places to identify simple errors:

  • Spelling: Go through the code to make sure spellings are correct.
  • Case: R is sensitive to upper or lower case.
  • Path: Is the file path correctly pointing to the right folder? Do we use double back slashes or one forward slash?
  • Quotation: Should quotation marks be used? Are they symmetric (beginning and ending) ones?
  • Parentheses: Are they matched?

How to get help

Using R involves continuous learning. So knowing how to get help is important. If we have questions about a particular function, say, library(), we can type in at the prompt either help(library) or ?library, and R will direct us to the documentation page explaining this function.

help(library) 
?library

More often, we need to seek help outside R itself. The last several years have witnessed an exponential increase in online communities and resources on the use of R. They are extremely valuable and useful, especially for beginner users. Here are a few possibilities.

  • A search engine that allows us to search for help on the official website, the CRAN, the archives of the mailing lists, and the documentation of R.

  • R-bloggers is a blog aggregator that allows us to search for help through all articles by R-user bloggers.

  • inside-R is a community site for R sponsored by Revolution Analytics that allows us to get help through searching blogs and asking questions.

  • Cookbook for R, created by Winston Chang, provides useful information on various topics, including R basics, numbers, strings, formulas, data input and output, data manipulation, statistical analysis, graphs, scripts and functions, and tools for experiments.

  • Quick-R, created by Rob Kabacoff and based on his popular book R in Action, provides useful information on the R code related to data input and management, basic and advanced statistics, and graphs.

Get hands-on with 1200+ tech skills courses.