Install & Update



Install R


The R language and its tools are built by people from around the world. They help you perform data analysis in an easy to follow step-by-step fashion, much like a recipe for cookies. And once you find your favorite recipe, you can use it over again on new data or even share it with your collaborators.


Install RStudio



RStudio is the handy user interface we use to write R scripts and keep our projects organized. It isn’t required to use R, but it makes things a whole lot easier.



Install RStudio

  1. Open the Software Center
  2. Search for RStudio
  3. Choose the blue R bubble
  4. Click [ Install ]

RStudio


Install R packages


R comes installed with many built-in functions and tools to help do your work. On top of this foundation, what is often referred to as base R, contributors from around the world have created tools that make R easier and accomplish more with your data. These add-ons are called packages, and are made available to everyone to download for free. Below are a few examples, grouped into general categories.

Packages used in this training

Load data

readr Load data from text files: tab, comma, and other delimited files
readxl Load data from Excel
janitor Clean and simplify column names
DBI Load data from databases
haven Load SAS, SPSS, and Stata files
sf Load data from GIS shapefiles


Manipulate data

dplyr Essential shortcuts to subset, summarize, rearrange, and join data sets.
tidyr Reshape tables and unpack multiple inputs stored in single cell.
stringr Tools to edit and clean text and character strings.
lubridate Tools to format dates and perform calculations based on time.


Charts and visuals

ggplot2 Essential package for plots and charts.


Maps

leaflet Display spatial data and make interactive maps.
sf Simple features for GIS and maps, a spatial format using data frames to perform spatial analysis.


General

remotes Install packages directly from online sources like GitHub and Gitlab.


Add R packages

To use a package you first need to install it – much like a free App for your phone. To get a jump start on the workshop, you can copy the text below and paste it into the RStudio console. The console is found on the left-side of the screen when you open RStudio.

new_packages <- c("readr", "readxl", "dplyr", "stringr", "tidyr",
                  "ggplot2", "lubridate", "janitor", "curl")

install.packages(new_packages)


Then press ENTER to begin the installation. If all goes well, you should start to see some messages appear similar to this, which provide information on the installation progress.


Did it work? Try running the code below to load the readr package from your library and see if it is installed.

library(readr)


Additional recommended packages

Charts and visuals

ggsave Export charts in various formats and sizes.
hrbrthemes , ggpomological, ggthemes Chart themes for ggplot.
viridis, wesanderson, ghibli Color palettes.
rmarkdown Write summary reports and save as PDF, Word document, presentation, or website.


Load data

RODBC Load data from Access and Oracle databases.
RMySQL, RPostgresSQL, and RSQLite for connecting to SQL databases.
pdftools Read PDF documents.
googledrive Read and write files to your Google Drive.
foreign Load data from Minitab and Systat.
R.matlab Load data from Matlab.


Manipulate data

stringr Tools to edit and clean text and character strings.


Maps

tidycensus Download Census and American Community Survey data.



Update R packages


There are two places to update R packages in RStudio.


1. In the Files and Plots area in the bottom right, under the Packages tab:

Click the green Update button next to Install.


2. In the Tools tab above at the top above the Code Editor:

Choose the 2nd option -> “Check for Package Updates…”