This file contains basic setup for R Exposure 1-4.
First of all, you will want to run the code in the following chunk to install the packages we will use.
if(!requireNamespace("tidyverse")) install.packages("tidyverse")
if(!requireNamespace("gapminder")) install.packages("gapminder")
If you are asked if you want to install packages from source, enter NO unless you know you have a compiler installed. If you’d like to be able to install packages from source, you can follow the instructions here.
While you can follow along using the .R
script files linked off the main course page, you’ll then have to deal with working directories and making sure data files are in the right spot. This is annoying! An easier solution is to download the entire workshop and work directly from the .R
scripts or slide .Rmd
files. To do this, go to the GitHub repository for the workshop (link). Then, click the green button and select download zip. Alternatively, you can click on the download button on the left side of the main workshop page.
You can then unzip this into a folder anywhere. You will find each lecture inside the lectures
folder and appropriate subfolders. Inside, you will want to open the .R
file (e.g. Unit_1_RStudio_and_RMarkdown.R
). This is a script file containing all code found in the slides.
Alternatively, you can also open the .Rmd file (e.g. Unit_1_RStudio_and_RMarkdown.Rmd
). You can then run the code inside the chunks from the actual slides! Note you can run the code in the chunks but will not be able to knit without the additional xaringan
slide creation package. If you want that, you can install it using install.packages("xaringan")
. Also, chunks with eval=FALSE
in their header are not meant to be run and may result in errors–but it won’t hurt anything!