Installing R and RStudio

adapted from datacarpentry.org

For this workshop, we will need R as well RStudio. R and RStudio are both completely free and open source software. While R is the underlying statistical computing environment, RStudio is the graphical IDE (integrated development environment) that makes using R easier, more intuitive, and interactive. Both are separate downloads and installations, and you will need to install R first, followed by RStudio. Once both are installed, you would just open and work in RStudio, which will run R in the background. Then you will install some R packages (collections of functions you can use in your own coding) which we are using for this workshop. Please install R version 4.3.1 or later and RStudio version 2023.09.0 or later.

1 Step 1 - follow instructions for your operating system

1.0.1 For Windows see Section 3

1.0.2 For MacOS see Section 4

1.0.3 For Linux see Section 5

2 Step 2 - install R packages

Open RStudio and Paste the following into your console on the left/bottom-left.

install.packages(c("broom", "cluster", "colorspace", "cowplot", "distill", "gapminder", "GGally", "gganimate", "ggbeeswarm", "ggiraph", "ggdendro", "ggdist", "ggforce","ggplot2movies", "ggrepel", "ggridges", "ggthemes", "gifski", "glue","knitr", "learnr", "naniar", "margins", "MASS", "Matrix","nycflights13", "palmerpenguins", "patchwork", "quarto", "rgdal", "rmarkdown","rnaturalearth", "sf", "shinyjs", "tableone", "tidyverse", "transformr", "umap"))

3 Windows

3.1 If you don’t have R and RStudio installed:

Go to https://posit.co/download/rstudio-desktop/ and follow this instruction for windows.

3.2 If you already have R and RStudio installed, check to see if updates are available.

RStudio: Open RStudio and click on Help > Check for updates. If a new version is available, quit RStudio, and download the latest version.

R: Upon starting RStudio, the version of R you are running will appear on the console. You can also type sessionInfo() in the console to display the version of R you are running. The CRAN website will tell you if there is a more recent version available. You can update R using the installr package, by running:

# installr is for windows only!
if( !("installr" %in% installed.packages()) ){install.packages("installr")} 

installr::updateR(TRUE) 

4 MacOs

4.1 Check your processor

adapted from https://docs.cse.lehigh.edu/determine-mac-architecture/

Make sure you are downloading and installing the right version of R and R Studio for your laptop’s CPU. Some Macs have an intel chip (also known as x64 or x86_64 architecture), while the newest macs have M1 or M2 chips (also known as ARM architecture).

To determine whether a Mac is running an Intel Processor or Apple ARM M1 or M2, click on the Apple Menu and select ‘About this Mac’:

click about this mac

From the ‘About this Mac’ screen, on the ‘Overview’ tab, look for a line that indicates either ‘Chip’ or ‘Processor’. If the line contains M1 or M2, the machine is running Apple Silicon. Alternatively, the word Intel indicates that the machine is running an Intel-based Core series processor.

M1 or M2

intel

4.2 If you don’t have R and RStudio installed:

Go to https://posit.co/download/rstudio-desktop/ and follow this instruction for MacOS.

4.3 If you already have R and RStudio installed, check to see if updates are available.

RStudio: Open RStudio and click on Help > Check for updates. If a new version is available, quit RStudio, and download the latest version.

R: Upon starting RStudio, the version of R you are running will appear on the console. You can also type sessionInfo() to display the version of R you are running. The CRAN website will tell you if there is a more recent version available. For this workshop install version 4.3.1 of R

5 Linux

5.1 If you don’t have R and RStudio installed:

Go to https://posit.co/download/rstudio-desktop/ and follow this instruction for your Linux OS.

5.2 If you already have R and RStudio installed, check to see if updates are available.

RStudio: Open RStudio and click on Help > Check for updates. If a new version is available, quit RStudio, and download the latest version.

R: Upon starting RStudio, the version of R you are running will appear on the console. You can also type sessionInfo() to display the version of R you are running. The CRAN website will tell you if there is a more recent version available. For this workshop install version 4.3.1 of R