R Tutorial: Census data in R: An overview

Kyle Walker shows how to pull U.S. Census data into R using tidycensus, tigris, and ggplot2. The Decennial Census counts everyone every ten years; the American Community Survey samples about 3 million households annually. You need a Census API key and functions like getdecennial() and getacs() to retrieve data as tidy data frames.
Chapters
Welcome. I'm Kyle Walker, your instructor. In this course, you'll learn the basics of working with and visualizing data from the U.S. census Bureau in R, with a focus on the Tidy Census, Tigris and ggplot2r packages. We'll first cover how to acquire US Census and American Community Survey data with the Tidy Census package. Then we'll learn how to wrangle census data using tidyverse tools. We'll then cover census spatial data in R using the TIGRIS package, and finally learn how to make attractive maps of Census data with ggplot2. I do research and consult in the fields of spatial demography and spatial data science, and I'm the lead developer of the R, Tidy Census, tigris and IDBR packages. The United States Census Bureau collects a vast amount of demographic, social, and economic data about the United States. The core resources for demographic data include the Decennial Census and the American Community Survey. The Decennial Census is conducted every 10 years and is a complete count of the United States population. The American community survey, or ACS, in contrast, is a survey of around 3 million households taken every year. Whereas the Decennial Census asks only about core demographic characteristics like age and race, the ACS asks a much broader range of questions. The U.S. census Bureau makes its data available to users via an application programming interface or API. The Tidy Census R package wraps the Decennial Census and ACS APIs, allowing R users to access census data directly. Before using the package, users must acquire a Census API key, then supply it to the Census API key function. The key is a 40 character alphanumeric code similar to the one shown on the slide setting. Install True will store the key on the user's computer for future use. You don't need to get an API key for this course, but you will need one to use Tidy Census on your own computers. The Get Decennial function in Tidy Census allows our users to access data from the 1990, 2000, or 2010 decennial US censuses, with 2010 as the default. In this example, we are acquiring data on total population by state. GETDECennial has two required geography, which specifies the level of aggregation for the census data, and variables a vector of census variable ID codes for which you'd like to request data. The function returns a tidy dataframe with GEOID and Name columns identifying the state, a variable column identifying the variable ID, and a value column showing the population value. The GetACS function allows R users to request data from the American Community Survey. The default data set obtained by GETACS is the 5 year 2012-2016. ACS sample as ACS data are based on survey samples, they represent estimates of population characteristics rather than exact data. In turn, ACS estimates are characterized by margins of error. The tidy dataframe returned by GETACS resembles the one returned by GET Decennial, but but with one key difference. Instead of a value column representing the data value, GETACS returns an estimate column with the data estimate and a margin of error column representing the margin of error around that estimate with a confidence level of 90%. Let's get started working with Census and ACS data using.
More from Richie

#359 My Best Friend is AI with Valerie Tiberius, Professor of Philosophy at University of Minnesota

How AI Agents Will Work While You Sleep | Ruslan Salakhutdinov, Professor at Carnegie Mellon

#358 How AI Agents Will Work While You Sleep | Ruslan Salakhutdinov, Professor at Carnegie Mellon







