Install & Update



Install R and RStudio


RStudio logo - 'RStudio' is written inside a blue glowing hexagon sticker.

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 share it with your collaborators.


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.



1. For state employees

State employees at MDH and other agencies may follow the steps below to install both R and RStudio all in one go:

  1. Open the Software Center
  2. Search for RStudio
  3. Choose the option with the blue R bubble shown below.
  • If it doesn’t appear for you submit a service ticket to your local MNIT friends.
  1. Click [ Install ]
  • Heads up, you may need to click [ Install ] a second time for it to fully get the message
  1. Once it completes, you can search for RStudio in your Windows search bar and click the RStudio App to open.

RStudio


2. For outside folks and friends

If you have the permissions to install software on your work computer, or you would just like to use R on your personal computer, you may download R and RStudio for free from the following trustworthy sources:

Installing R

  1. Go to https://cloud.r-project.org/
  2. Click on the download link for your operating system, then click on base.
  3. Click on the download link at the top of the page to download R.
  4. Click on the downloaded file to install R.

Installing RStudio

After you have installed R, you can install RStudio.

  1. Go to https://rstudio.com/products/rstudio/download/
  2. Scroll down to the table, locate your operating system, and click the download link.
  3. Click on the downloaded file to install RStudio.


3. In the cloud

As a stop gap until you are able to install R locally, you can create an account at the link below and then you can use R right in your browser for the training.



The sections below are for reference and do not need to be completed before R camp begins.


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)


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…”