Learning R with County Case Studies: Synthesizing Multiple Data Sources to Study Agricultural Change

<p dir="auto">This is a series of research modules designed to both teach beginning R users how to work with data and lead undergraduates through research by constructing case studies of individual counties using public data. These modules are designed to be completed asynchrounously. If students work on these independently, weekly debriefing sessions are helpful to work students through any difficulties they encounter. Students in a class with 26 required research hours typically completed between 3-4 modules, as well as preparing and presenting both a lightning talk and a team oral talk or poster of their research.</p> <p dir="auto">An accompanying peer-reviewed publication about these materials and their delivery is in preparation.</p> <div class="markdown-heading" dir="auto"> <h1 class="heading-element" dir="auto" tabindex="-1">Contents</h1> Each research module is contained in a separate folder containing a PDF of the instructions provided to students, an editable Quarto source file for the instructions, and instructor notes that contain the data sources and notes on teaching the modules.</div> <div class="markdown-heading" dir="auto"> <h2 class="heading-element" dir="auto" tabindex="-1">Module 1: Getting Started in R</h2> Objectives:</div> <ol dir="auto"> <li>Download R and RStudio on your personal computer.</li> <li>Create a single-value object, a vector, and a data frame.</li> <li>Use number and character data.</li> <li>Produce a Quarto report in PDF format to save a record of your work.</li> </ol> <div class="markdown-heading" dir="auto"> <h2 class="heading-element" dir="auto" tabindex="-1">Module 2: Navigating Data</h2> Objectives</div> <ol dir="auto"> <li>Read data into R.</li> <li>Use commands that tell us information about a data frame.</li> <li>Create subsets of data based on positions and conditions.</li> <li>Use subsets to calculate metrics from two data sources.</li> <li>Report on the average age of residents, average age of agricultural producers, population size, percentage of residents in agricultural producer households, and percent of acres used for agriculture in your case study county.</li> </ol> <div class="markdown-heading" dir="auto"> <h2 class="heading-element" dir="auto" tabindex="-1">Module 3: Agricultural Statistics, Part 1</h2> Objectives:</div> <ol dir="auto"> <li>Review percent calculations used in Module 2 to calculate statistics on producer gender and race.</li> <li>Use <code>unique</code> to calculate the variety of commodities produced by a county.</li> <li>Use <code>ifelse</code> to assign categories and aggregate to calculate summary statistics for those categories (farm size, farm ownership).</li> </ol> <div class="markdown-heading" dir="auto"> <h2 class="heading-element" dir="auto" tabindex="-1">Making Figures</h2> At this point, students may need to make figures for a presentation of their research. The attached tutorial is not an in-depth module on data visualization, but merely a template for students who need to make figures with limited time.</div> <p dir="auto">Objectives:</p> <ol dir="auto"> <li>Make comparison plots with <code>ggplot2</code>.</li> </ol> <div class="markdown-heading" dir="auto"> <h2 class="heading-element" dir="auto" tabindex="-1">Module 4: Agricultural Statistics, Part 2</h2> Objectives:</div> <ol dir="auto"> <li>Use subsets, joins, and calculations across rows to quantify 20-year change in farm size and ownership.</li> <li>Use calculations based on a previous row (with <code>lag</code>) to quantify 20-year change in 5-year intervals for agricultural land use and agricultural sales.</li> <li>Use the <code>dplyr</code> package for data cleaning.</li> </ol> <div class="markdown-heading" dir="auto"> <h2 class="heading-element" dir="auto" tabindex="-1">Module 5: Demographic Data</h2> Objectives:</div> <ol dir="auto"> <li>Clean data by extracting column names from a multi-row header, filtering with <code>%in%</code> statements, and matching variable codes to their meanings.</li> <li>Increase reproducibility by using the <code>tidycensus package</code> to pull data from the online American Community Survey data portal.</li> <li>Calculate employment metrics (percent residents employed in agriculture, manufacturing, hospitality, and technology), residents over retirement age, and net migration rate.</li> </ol> <div class="markdown-heading" dir="auto"> <h2 class="heading-element" dir="auto" tabindex="-1">Module 6: Reproducible Data Retrieval: Pulling Data Directly into R</h2> Objectives:</div> <ol dir="auto"> <li>Navigate the US Census API to locate variables of interest from the American Community Survey.</li> <li>Use the <code>tidycensus</code> package to pull data from the American Community Survey and calculate a descriptive metric of interest.</li> <li>Use the NASS Quick Stats page to locate variables of interest from the Census of Agriculture.</li> <li>Use the <code>rnassqs</code> package to pull data from the Census of Agriculture and calculate a descriptive metric of interest.</li> </ol> <div class="markdown-heading" dir="auto"> <h2 class="heading-element" dir="auto" tabindex="-1">Module 7: Working with Spatial Data</h2> Objectives:</div> <ol dir="auto"> <li>Use the <code>sf</code> package to explore and visualize vector data.</li> <li>Use the <code>terra</code> package to explore and visualize raster data.</li> <li>Use <code>sf</code> and <code>tigris</code> to retrieve a shapefile of a case study county.</li> <li>Use a shapefile to crop a raster.</li> <li>Calculate summary statistics for a raster.</li> </ol> <div class="markdown-heading" dir="auto"> <h2 class="heading-element" dir="auto" tabindex="-1">Module 8: Spatial Data, Part 2</h2> Objectives:</div> <ol dir="auto"> <li>Use spatial summary statistics to calculate average agricultural quality.</li> <li>Crop vector data and calculate land management percentages.</li> <li>Use <code>freq</code> to calculate land cover percentages.</li> </ol> <div class="markdown-heading" dir="auto"> <h2 class="heading-element" dir="auto" tabindex="-1">Module 9: Migration Data</h2> Objectives:</div> <ol dir="auto"> <li>Calculate statistics for multiple counties at once using <code>summarise</code>.</li> <li>Determine the difference in population size and density from source counties to study area counties.</li> <li>Join land cost data to migration data and calculate the difference in land value, using <code>terra::extract</code>.</li> <li>Determine the average household size of source counties.</li> </ol>

Institutions

Publication Details

Journal
QUBES
Published
2025-09-12
DOI
https://doi.org/10.25334/kqh0-xh15
Primary Topic
Geochemistry and Geologic Mapping
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Learning R with County Case Studies: Synthesizing Multiple Data Sources to Study Agricultural Change

QUBES
Geochemistry and Geologic Mapping
article

Learning R with County Case Studies: Synthesizing Multiple Data Sources to Study Agricultural Change

article en

Abstract

<p dir="auto">This is a series of research modules designed to both teach beginning R users how to work with data and lead undergraduates through research by constructing case studies of individual counties using public data. These modules are designed to be completed asynchrounously. If students work on these independently, weekly debriefing sessions are helpful to work students through any difficulties they encounter. Students in a class with 26 required research hours typically completed between 3-4 modules, as well as preparing and presenting both a lightning talk and a team oral talk or poster of their research.</p> <p dir="auto">An accompanying peer-reviewed publication about these materials and their delivery is in preparation.</p> <div class="markdown-heading" dir="auto"> <h1 class="heading-element" dir="auto" tabindex="-1">Contents</h1> Each research module is contained in a separate folder containing a PDF of the instructions provided to students, an editable Quarto source file for the instructions, and instructor notes that contain the data sources and notes on teaching the modules.</div> <div class="markdown-heading" dir="auto"> <h2 class="heading-element" dir="auto" tabindex="-1">Module 1: Getting Started in R</h2> Objectives:</div> <ol dir="auto"> <li>Download R and RStudio on your personal computer.</li> <li>Create a single-value object, a vector, and a data frame.</li> <li>Use number and character data.</li> <li>Produce a Quarto report in PDF format to save a record of your work.</li> </ol> <div class="markdown-heading" dir="auto"> <h2 class="heading-element" dir="auto" tabindex="-1">Module 2: Navigating Data</h2> Objectives</div> <ol dir="auto"> <li>Read data into R.</li> <li>Use commands that tell us information about a data frame.</li> <li>Create subsets of data based on positions and conditions.</li> <li>Use subsets to calculate metrics from two data sources.</li> <li>Report on the average age of residents, average age of agricultural producers, population size, percentage of residents in agricultural producer households, and percent of acres used for agriculture in your case study county.</li> </ol> <div class="markdown-heading" dir="auto"> <h2 class="heading-element" dir="auto" tabindex="-1">Module 3: Agricultural Statistics, Part 1</h2> Objectives:</div> <ol dir="auto"> <li>Review percent calculations used in Module 2 to calculate statistics on producer gender and race.</li> <li>Use <code>unique</code> to calculate the variety of commodities produced by a county.</li> <li>Use <code>ifelse</code> to assign categories and aggregate to calculate summary statistics for those categories (farm size, farm ownership).</li> </ol> <div class="markdown-heading" dir="auto"> <h2 class="heading-element" dir="auto" tabindex="-1">Making Figures</h2> At this point, students may need to make figures for a presentation of their research. The attached tutorial is not an in-depth module on data visualization, but merely a template for students who need to make figures with limited time.</div> <p dir="auto">Objectives:</p> <ol dir="auto"> <li>Make comparison plots with <code>ggplot2</code>.</li> </ol> <div class="markdown-heading" dir="auto"> <h2 class="heading-element" dir="auto" tabindex="-1">Module 4: Agricultural Statistics, Part 2</h2> Objectives:</div> <ol dir="auto"> <li>Use subsets, joins, and calculations across rows to quantify 20-year change in farm size and ownership.</li> <li>Use calculations based on a previous row (with <code>lag</code>) to quantify 20-year change in 5-year intervals for agricultural land use and agricultural sales.</li> <li>Use the <code>dplyr</code> package for data cleaning.</li> </ol> <div class="markdown-heading" dir="auto"> <h2 class="heading-element" dir="auto" tabindex="-1">Module 5: Demographic Data</h2> Objectives:</div> <ol dir="auto"> <li>Clean data by extracting column names from a multi-row header, filtering with <code>%in%</code> statements, and matching variable codes to their meanings.</li> <li>Increase reproducibility by using the <code>tidycensus package</code> to pull data from the online American Community Survey data portal.</li> <li>Calculate employment metrics (percent residents employed in agriculture, manufacturing, hospitality, and technology), residents over retirement age, and net migration rate.</li> </ol> <div class="markdown-heading" dir="auto"> <h2 class="heading-element" dir="auto" tabindex="-1">Module 6: Reproducible Data Retrieval: Pulling Data Directly into R</h2> Objectives:</div> <ol dir="auto"> <li>Navigate the US Census API to locate variables of interest from the American Community Survey.</li> <li>Use the <code>tidycensus</code> package to pull data from the American Community Survey and calculate a descriptive metric of interest.</li> <li>Use the NASS Quick Stats page to locate variables of interest from the Census of Agriculture.</li> <li>Use the <code>rnassqs</code> package to pull data from the Census of Agriculture and calculate a descriptive metric of interest.</li> </ol> <div class="markdown-heading" dir="auto"> <h2 class="heading-element" dir="auto" tabindex="-1">Module 7: Working with Spatial Data</h2> Objectives:</div> <ol dir="auto"> <li>Use the <code>sf</code> package to explore and visualize vector data.</li> <li>Use the <code>terra</code> package to explore and visualize raster data.</li> <li>Use <code>sf</code> and <code>tigris</code> to retrieve a shapefile of a case study county.</li> <li>Use a shapefile to crop a raster.</li> <li>Calculate summary statistics for a raster.</li> </ol> <div class="markdown-heading" dir="auto"> <h2 class="heading-element" dir="auto" tabindex="-1">Module 8: Spatial Data, Part 2</h2> Objectives:</div> <ol dir="auto"> <li>Use spatial summary statistics to calculate average agricultural quality.</li> <li>Crop vector data and calculate land management percentages.</li> <li>Use <code>freq</code> to calculate land cover percentages.</li> </ol> <div class="markdown-heading" dir="auto"> <h2 class="heading-element" dir="auto" tabindex="-1">Module 9: Migration Data</h2> Objectives:</div> <ol dir="auto"> <li>Calculate statistics for multiple counties at once using <code>summarise</code>.</li> <li>Determine the difference in population size and density from source counties to study area counties.</li> <li>Join land cost data to migration data and calculate the difference in land value, using <code>terra::extract</code>.</li> <li>Determine the average household size of source counties.</li> </ol>

QUBES
Boise State University (US)
Zero hunger
Openalex Percentile: Top 44%
Geochemistry and Geologic Mapping
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.