Mark Nepf

PhD Candidate

University of Washington
Evans School of Public Policy & Governance
Contact

Mark Nepf

Code Vignettes

These vignettes are designed to make learning R and working with data more approachable through clear, step-by-step explanations. Each guide breaks down a technical concept or workflow into manageable pieces, explaining not only what the code does, but how and why each step fits into the larger process. The goal is to help readers build their understanding from the ground up, develop practical skills, and feel more confident applying what they learn to their own work.

These resources are intended to be useful both as introductions for those encountering a concept for the first time and as references for those looking to revisit a particular technique. I add vignettes to this page as topics come up in my research. If there is a something specific you would like to see, please reach out and let me know!

Reshaping Data

An introduction to reorganizing data between long and wide formats in R using pivot_longer and pivot_wider. This guide explains how these formats differ, how to move between them, and how to use the key arguments of each function. Examples demonstrate how the choice of data format can affect common tasks such as summarizing, visualizing, and comparing data.

Implementing for Loops

An introduction to using for loops in R to automate repetitive tasks and multi-step analyses. This guide explains the basic structure of for loops, including vectors, index variables, and the code executed during each iteration. It also introduces nested loops and strategies for storing results, including using lists to save dataframes and model objects. Examples demonstrate how loops can be used to repeatedly fit statistical models across groups, as well as how to determine when a for loop is preferable to vectorized or grouped approaches.

Accessing Census Data

A practical introduction to accessing U.S. Census Bureau data directly through R using the tidycensus package. This guide covers how to obtain and install a Census API key, find appropriate Census variables and datasets, and download Decennial Census and American Community Survey data. It also introduces basic strategies for cleaning and reshaping Census data, as well as automating downloads across multiple years and states.

Introduction to Spatial Data

An introduction to working with vector spatial data in R using the sf package. This guide explains the fundamentals of spatial data and introduces Coordinate Reference Systems, common spatial data file formats, and practical approaches for importing spatial data. Examples are provided using King County, Washington transit and parks.

Working with eBird Data

A step-by-step guide to accessing and exploring personal bird observations in R using eBird data. This guide explains how to download and clean observation records, access eBird's taxonomic data through an API, and connect observations to species information on the eBird website. Examples demonstrate how to combine datasets, create links to individual species pages, and visualize bird sightings on an interactive map using leaflet.

Measuring Park Access

This vignette accompanies a published study (DOI, PDF) of park access in King County, Washington and offers a practical guide to measuring accessibility and analyzing spatial patterns using R. The code demonstrates how to generate walking-time isochrones using OSRM (Open Source Routing Machine) and quantify access based on the number of parks reachable within a 30-minute walk. It also introduces spatial weights matrices, Local Moran's I cluster analysis, and bivariate analysis to examine the spatial association between park accessibility and youth populations.