These package instructions should be used after you’ve followed these instructions and installed R and RStudio.

  1. Open RStudio. Copy and paste the following lines of code into the Console window of RStudio to install a few key packages.
pkgs <-  c( "arm", "boot", "devtools", "Epi", "fivethirtyeight",
            "gapminder", "here", "Hmisc", "infer", "janitor",
            "knitr", "magrittr", "markdown", "mosaic", "naniar",
            "NHANES", "patchwork", "rmarkdown", "rms", "tableone", 
            "tidymodels", "tidyverse" )
            
install.packages(pkgs)
  1. Execute those commands by hitting Enter.

  2. Now, go to the Packages tab on the right side of your RStudio screen, and click on Update.

  3. This will bring up a dialog box. I usually click Select All, then click Install Updates.

    • A popup box may appear, asking “Do you want to install from sources the packages which need compilation?” to which I usually answer No. A Yes response leads to a slower installation, but can solve problems if you still have them after updating.
    • This may take a few minutes. As long as you’re seeing activity in the Console window, things are progressing.
    • Eventually, you’ll get a message that “The downloaded source packages are in …” with a directory name. That’s the sign that the updating is done.
    • Updating packages is something you’ll do occasionally throughout the semester, mostly when a problem happens.
  4. Finally, choose File … Quit Session from the top menu, and accept RStudio’s request to save your workspace. This will eliminate the need to re-do these steps every time you work in R.

Note: A Windows Issue

If you are using Windows, and get messages during installation that the latest version of RTools needs to be installed, you can usually just ignore them. If you don’t want to ignore them, go here to download and install RTools for Windows.

Installing a Single Package

If you want to install a single package, you can do so by finding the word Packages on the right side of your RStudio screen.

  1. Click on the Packages tab to start installing the packages you’ll need.
  2. Click Install, which will bring up a dialog box, where you can type in the names of the packages that you need. These should be separated by a space or comma. Be sure to leave the Install dependencies box checked.
    • A popup box may appear, asking “Do you want to install from sources the packages which need compilation?” to which I usually answer No. A Yes response leads to a slower installation, but can solve problems if you still have them after updating.
    • This may take a few minutes. As long as you’re seeing activity in the Console window, things are progressing.
    • Eventually, you’ll get a message that “The downloaded source packages are in …” with a directory name. That’s the sign that the updating is done.

Questions? Email Dr. Love at Thomas dot Love at case dot edu. (Note that he will be away August 6-16.)

CWRU Logo