Getting Help With an R Problem

Dec 7, 20185 min read

R is a powerful tool with a challenging learning curve, especially in the beginning. When you're stuck trying to do something in R (or even if you don't know where to begin), know that there are resources online for you to turn to.

First, let's make sure you are in the right place: this article is aimed at people who are using R and want to know how to find help with a particular problem, a problem like "I keep getting an error and I don't know why," or "I'm trying to do X in R and keep getting wrong results," or "Is it possible to do Y in R, and where should I start?" If you are just looking to get started learning R, please see our article Getting started with R.

The next section of this article covers several popular, free places to get help from real people: Stack Overflow, Twitter, RStudio Forums and Reddit, and talks about when each one is most appropriate and how to use it effectively, and also mention alternatives. You can learn lots about using R well by simply browsing these sites, and when you have specific problems you can get high-quality, personalized help within a couple hours of creating an account—if you use them right. However, before you post your own question any of these resources, we strongly recommend learning how to self-serve as well as possible, which is covered in the second half of this article.

Help Checklist

If you're having trouble, following this checklist can help.

  1. Function documentation - especially when trying a function for the first time or trying new settings/arguments.
  2. Package documenation - when available, this is usually the nicest way to get to know a new package. Many packages have nice introductions, and some have multiple vignettes, focused on different areas. Check the package homepage on CRAN or Github these resources.
  3. Search for the error - when you're getting an error or warning, Googling the error message verbatim often turns up a solution.
  4. Search for similar problems - for coding questions, Stack Overflow is a great place to turn. Search within specific tags to get relevant results. Cross Validated is a similar forum for statistics questions. The RStudio Community Forums are open to a wide range of topics.
  5. Isolate the issue - you probably know the line where a problem manifests itself, but it most cases you'll need to backtrack to find the source of the problem. Step through your script one line at a time, checking your assumptions about the steps along the way.
  6. Make a minimal reproducible example. Strip away everything that isn't directly related to the issue, considering both your code and data. Try to find the smallest subset of data and the fewest lines of code that still demonstrate your problem. Make the problem as simple as possible to make it easier to solve.

This isn't a linear process, take what's applicable to your case, and hop around between suggestions that seem likely. If you're still stumped, take your minimal reproducible example and turn to outside help.

Outside Help

  • Ask a new questions on Stack Overflow. There are fairly strict community norms at Stack Overflow, which make it very good for answering well-defined questions about coding, but not a good place for less well-defined questions and general advice. If your problem is specific and about coding (i.e., not about  statistics or not a broad, general query) and  you provide a minimal reproducible, someone will often give you a detailed solution very quickly.
  • RStudio Community Forums are an excellent place for help, especially with RStudio, R packages in the tidyverse. It's a much less strict forum than Stack Overflow, which makes it a  more welcoming place for general advice.
  • Twitter, the #rstats tag is active on Twitter, and full of community events, announcements, and people getting help and advice. I wouldn't recommend using Twitter just for help with R, but if you are already on Twitter, follow some R icons like @jennybryan and @hadleywickham to enrich your feed, and the #tidytuesday tag curates a data analysis and visualization challenge each Tuesday.

Self-Help

How to read R function documentation

One of R's great strengths is its documentation, though it may seem arcane until you've identified how to read it well. Always start with the Arguments section near the top, that should give you an idea of what each argument does, and then the Examples section at the bottom. Running the examples, one line at a time, is a great way to explore a function's capabilities.

Search within a single documentation page for key terms. RStudio makes this easy with a separate "find" box.

Other R documentation: package vignettes

Many R packages, and especially high-quality R packages, include long-form documentation called "vignettes." For example, the hugely popular dplyr package has 5 vignettes on various topics. You can find them all on the CRAN package page, or from your R console with the command vignette(package = "dplyr"). Similarly, they can be view online following the links from CRAN, or locally from R with the command vignette() command, naming one of the vignettes listed for the package, e.g., vignette(topic = "window-functions"). The Introduction to dplyr vignette is excellent, and should be required reading for anyone who uses the package.

In summary, if your R problem is with a particular package (or functions in that package), check to see if the package comes with vignettes with worked examples. If so, they can often be extremely helpful.

Need more help? Contact us today to find out how Project Evident can help your organization better use evidence to improve outcomes for the communities you serve.