https://machlis.com/Workshop2024/
Auto-advance: https://machlis.com/Workshop2024/setup.html
Download R software (for either Windows or Mac) and the RStudio desktop application. Links for both at https://posit.co/download/rstudio-desktop/
If you can’t or don’t want to get R running on your own local system, you can run R and RStudio in the cloud for free. Sign up at https://posit.cloud/plans/free.
This gives you 25 compute usage hours / month, so use wisely.
These are sometimes needed for certain R package installations locally, better to be safe and avoid problems:
Rtools, a regular software package. Find, download and install the appropriate Rtools.exe file for your system here: https://cran.r-project.org/bin/windows/Rtools/. You probably need RTools 4.4 if you are installing the current version of R.
Install Xcode, Apple’s development environment, which should be available in the Mac App Store.
File > New Project
DON’T save your workspace if it asks!!!
To prevent it from asking: Tools > Global Options > General > Never for “Save workspace to .RData on exit”
https://www.machlis.com/R4Journalists/a-brief-introduction-to-rstudio.html
It will be helpful to understand how to use the RStudio console, create an R script file, and run R code before the workshop. This way, we can get right to learning R!
Install the 3 packages that are suggested in the book sections plus several more we’ll be using. You can do all that by running the R command
This works in Post Cloud as well.
Install the tidycensus, tigris, and mapview packages with install.packages(c("tidycensus", "tigris", "mapview"))
. Get a US Census Bureau API key at http://api.census.gov/data/key_signup.html
Run this in your console to store your Census API key in R. Leave out the , install = TRUE
if you are not on your own local computer.
The pacman package’s p_load()
function will install a package if it’s not already installed, or load it if it’s already installed. Doesn’t require quotations around the package names or the c() to list them.
If we’re worried about Internet in the classroom, you can download the data files to your project directory in advance:
download.file("https://raw.githubusercontent.com/smach/SampleData/refs/heads/main/states.csv",
destfile = "states.csv"
)
download.file("https://www.machlis.com/Workshop2024/us_presidential_2parties_2016_2020.csv",
destfile = "election_data.csv"
)
download.file('https://github.com/sfirke/janitor/raw/refs/heads/main/dirty_data.xlsx', "dirty_data.xlsx", mode = "wb")
If you have time and want to get ahead, we’ll be going through Chapter 3 sections 3.1 to 3.3 in the workshop.