Before You Begin

Linking NaNDA With Your Data · Breakout 2, Intermediate

The short version

You do not need to install anything, and you do not need to run any code.

This session is a guided read-along. Robert Melendez writes and runs the code live on screen. Everything he types is already written out, with its output, in the notebook. Read along in a second window, or watch and come back to it afterward.

Running the code yourself during the session is optional. The setup is below. If it does not work on the day, follow along.

What you’ll get

Notebook (read-along, all outputs shown) Linking NaNDA With Your Data: notebook
Everything as a single download Workshop materials (ZIP)
Source and version history GitHub repository
Archived and citable DOI 10.5281/zenodo.23071407

The ZIP contains:

  • the synthetic dataset and its codebook
  • the crosswalk file, the lookup table that turns ZIP codes into Census ZCTAs
  • the notebook source, with its Stata and Python equivalents
  • an offline copy of this site

The NaNDA files themselves are not in the ZIP. NaNDA is distributed through ICPSR, which asks for a free account, so you download your own. It takes about five minutes. The steps are in the optional setup below and in data/nanda/README.md inside the ZIP. You only need them to run the code.

If you do want to run along

  1. R (4.3 or newer): cran.r-project.org

  2. RStudio Desktop (free): posit.co

  3. Open RStudio and run:

    install.packages(c("tidyverse", "here", "janitor"))

    (readxl, which reads the crosswalk, installs as part of tidyverse.)

  4. Download and unzip the workshop materials.

  5. Get the NaNDA files from ICPSR. Sign in at icpsr.umich.edu with a free account, then download these in R format (Stata and delimited versions are on the same pages):

    Unzip each one, extract the data file from the nested folders, and put all four in data/nanda/ inside the unzipped workshop folder. data/nanda/README.md has the filenames and the same steps in more detail.

  6. Open workshop.Rproj, then open notebook.qmd, and run the first chunk. If it prints a preview of the data, you’re set.

Stata and Python users: equivalent .do files are in the stata/ folder of the ZIP and .py scripts in python/. The live session is in R, but these do the same thing step for step and are yours to keep. The R code is also there as plain scripts in r/, and each folder carries a second script for data that already has a 2010 tract ID instead of a ZIP code.

ImportantIf setup doesn’t work

Save the troubleshooting for later. The notebook shows every output. Follow along on screen, and email us afterward: nanda-admin@umich.edu.

What we assume you already know

You have used R, Stata, or another statistical package to open a dataset and join two tables. This session covers what goes wrong when you link individual-level data to neighborhood-level data, and how to catch it, in whichever language you use.