Download the tutorial file, knit it to see the complete analysis, then run it chunk by chunk to understand each step.
In this lab you will construct a composite Economic Hardship Index from five US Census variables, evaluate its reliability using Cronbach's alpha, and map the results at three geographic scales — US counties (national), Arizona census tracts (state), and Maricopa County block groups (neighborhood).
The tutorial walks through every step with fully working code. Knit it first to see the finished product, then go back and run chunk by chunk to understand how it works.
tidycensus::get_acs()psych::alpha()ggplot2 + patchworkCreate this folder structure before downloading anything. Move the downloaded .qmd into PAF516/Lab1/ before opening it in RStudio.
PAF516/
Lab1/
Lab1_Tutorial.qmd ← downloaded tutorial (do not edit)
Lab1_Tutorial.html ← auto-generated when you knit
Lab1_Assignment_Howell.qmd ← your renamed assignment copy
Lab1_Assignment_Howell.html ← submit this to Canvas
Lab2/ Lab3/ ...
R needs a system-level compiler to install certain packages used in this course. You only need to do this once — it applies to all future labs.
Windows: Run these two lines in your RStudio Console:
install.packages("installr")
installr::install.Rtools()
Mac: Run this line in your Terminal (Applications → Utilities → Terminal):
xcode-select --install
Once complete, restart RStudio before proceeding.
Lab1_Tutorial.qmd in RStudiopackages chunk (labeled #| label: packages)renv block only runs once automaticallyThe lab pulls live data from the Census Bureau. If you don't have a key yet:
census_api_key("YOUR_KEY_HERE", install = TRUE)Click the Render button (blue arrow, top of editor) or press Cmd+Shift+K / Ctrl+Shift+K. This produces Lab1_Tutorial.html with all results — maps, tables, and the correlation matrix. Review the output to see what the completed analysis looks like.
Place your cursor inside any code chunk and press the run shortcut. Output appears inline. Fix any errors before moving on. This is how you understand what each step does.
| Action | Mac | PC |
|---|---|---|
| Run current chunk | Cmd+Return | Ctrl+Enter |
| Run all chunks above | Cmd+Option+P | Ctrl+Alt+P |
| Knit / Render | Cmd+Shift+K | Ctrl+Shift+K |
| Step | What It Does |
|---|---|
| Step 1 | Retrieve Census variables with get_acs() — Arizona census tracts |
| Step 2 | Reshape to wide format and compute poverty, unemployment, education, and insurance rates |
| Step 3 | Run psych::alpha() — assess reliability of the 5-item index |
| Step 4 | Build the composite index (z-score row mean) and visualize its distribution |
| Step 5 | Pull county-level data for the entire US and map national hardship patterns |
| Step 6 | Map the index across Arizona census tracts |
| Step 7 | Pull Maricopa County block groups and map neighborhood-level variation |
| Step 8 | Combine all three maps side-by-side using patchwork |
Right-click → Save Link As. Save directly to your PAF516/Lab1/ folder. Do not open in the browser.