Approaching package issues systematically
Given the amount of tools the average data person uses daily, we need to reduce the hurdles to as many “easy tasks” as possible. To help other poor souls that don’t want to think too hard when struggling to install R packages referenced in tutorials or other media, I’ve put together a simple flow chart. The basic troubleshooting guide can be followed in the flow chart. However additional detailed instructions and links can be found below the image.
Additional instructions for Package Install troubleshooting flow chart
Is the package available on CRAN?
- Unfortunately CRAN does not have a search but you can usually find the package by googling “CRAN R <package name>”
Do you have the right version of base R?
- To identify your R version, execute the command “Version” and the output will indicate your installed base R version. In the screenshot, I have version 3.4.3
- To install a new version of R, visit their download page
- If the install worked, you will get a message along the lines of “The downloaded binary packages are in <filepath> “
Install via R-Studio package interface
- This is a very handy tip which prevents silly typos. The tip was given by Albert Kim in reply to my #rstats tweet. He documents this in his awesome book: Modern Dive An Introduction to Statistical and Data Sciences via R.
Locate the package repo and install via devtools
- Typically the easiest way to locate the package repo is by googling “r package <package name>”. In the case of the emo R package I found it here: https://github.com/hadley/emo
- Install the package from the repo via devtools. This simply involves installing and loading the devtools package and then executing the appropriate “install_” command from the docs. In the case of the emo package, the following code will work.
# OR MAC and Linux users can simply do:
Thank you for taking the time to read this guide. I certainly hope that it will help people spend less time thinking about package install debugging and leave more time for fun data analysis and exploration. Please feel free to let me know your thoughts in the comments or on twitter. Thanks!
Original Post can be found here.