, 21 tweets, 7 min read Read on Twitter
A basic guide to trouble shooting problems with #rstats
(A thread for my students and others new to R)

Something in R not working? Weird error message?
Go through this list of steps to try to resolve the problem. [thread; suggestions & other tips highly welcome]
@DimperioJane
1) Did you run a line of code without a ")" at the end?

Look at your code in the console. Is there a little "+" at the far left? R is probably waiting for a complete line of code. Click into the console, press ESC, add the ")", and try again
2) Is R waiting for user input?
Occasionally R will ask for user input via a pop up Window or within the console itself. Look in the console see if you need to give a numeric response (option 1, option 2) or look for the GUI's popup.
2.5) The above problem often happens when installing packages in a RMarkdown (.Rmd) file and its set to render "chunk" output inline. Check what's going on in the console.
3) Is library(package_name) not working?
Make sure you've spelled the name of the package correctly. 😂

(The error message is a bit ambiguous - it could be read as saying you haven't downloaded that package, rather than such a package doesn't actually exist at all).
4) Are you trying to use a package you just installed?

Often when you first install a package (download it from CRAN) you need to re-start R. This can be done quickly with Ctrl+Shift+F10
5) Is R crashing / code not working when you use a particular function from a package?

Try re-installing the package

install.packages("the_package")
library(the_package)

(you may have to then restart)

Your version of the package may be out of sync w/ other packages or w/ R
6) Are you using RMarkdown and having the output of chunks displayed "inline".
Set it to "console" and try again. On rare occasions knitr/rmarkdown appear to get cranky.
7) Can't figure out what the problem is?
Try updating commonly used packages.

You can do this by hand with install.package(...)

You can update ALL your packages with
update.packages(ask = F)

This takes several minute on my computer because I have MANY packages.
8) Still problems? Re-install R and/orRStudio
Before re-installing R, save a list of all your packages (otherwise you'll have to do it by hand)

packs <- installed.packages()
packs <- mypacks[c(1:2),]
# save packs as .csv or other format
# reload .csv
install.packages(packs[,1])
9) STILL problems? Here are a number of suggestions
Try your code on RStudio cloud, which lets you use different versions of R (you'll have to install relevant packages)
10) You can toggle between different versions of R in RStudio if a) You are windows and b) you've already installed those versions of R. This is done through the options menu

support.rstudio.com/hc/en-us/artic…
11) Switching between versions of R takes slightly more work on a Mac. You may want to try out Rswitch

support.rstudio.com/hc/en-us/artic…

mac.r-project.org
12) Try running the code on a different computer, especially a PC if you are using a Mac. Occasionally problems will be associated with a particular operating system.
13) Update your computer's operating system
14) For all problems, googling the error message is your best first step for finding help - its what the "computer person" who helps you is going to do 😜
Good luck! I currently test the code for my teaching package on three computers, and I still run into problems when I release things out into the wild. Usually you don't have to go much beyond updating a package, or updating R.
Addendum: make sure you are using 64 bit no 32 bit
also, be aware that updating packages can sometimes break older code / when a new version of R is released there may be a lag b/f packages get updated to be compatible w/it. You can install old vs of packages & of R if necessary; also checkout the packrat pckg
h/t @davidbraze
@davidbraze also, reopening an old workspace (as is the default in R...) c an create problems. best to set RStudio to not save your workspace on closing / don't reload workspace on load
see community.rstudio.com/t/defaults-of-…
@davidbraze the searcher and errorist packages looks like a great tool for investigating error messages

cran.r-project.org/web/packages/s…

h/t @McAleerP
Missing some Tweet in this thread?
You can try to force a refresh.

Like this thread? Get email updates or save it to PDF!

Subscribe to Nathan Brouwer
Profile picture

Get real-time email alerts when new unrolls are available from this author!

This content may be removed anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Follow Us on Twitter!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just three indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3.00/month or $30.00/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!