Searching for data with tidycensus

Analyzing US Census Data in R

Kyle Walker

Instructor

Searching for Census variables

To find Census variable IDs, use:

  • Online resources like Census Reporter
  • Built-in variable searching in tidycensus
Analyzing US Census Data in R

Choosing a dataset to search

v16 <- load_variables(year = 2016,
                      dataset = "acs5",
                      cache = TRUE)                    
v16
# A tibble: 22,855 x 3
   name      label                                  concept                     
   <chr>     <chr>                                  <chr>                       
 1 AIANHH    FIPS AIANHH code                       <NA>                        
 2 AIHHTLI   American Indian Trust Land/Hawaiian H~ <NA>                        
 3 AITSCE    American Indian Tribal Subdivision (F~ <NA>                        
 4 ANRC      Alaska Native Regional Corporation (F~ <NA>                        
 5 B00001_0~ Estimate!!Total                        UNWEIGHTED SAMPLE COUNT OF ~
 6 B00002_0~ Estimate!!Total                        UNWEIGHTED SAMPLE HOUSING U~
# ... with 22,84 more rows
Analyzing US Census Data in R

Filtering a variables dataset

library(tidyverse)
B19001 <- filter(v16, str_detect(name, "B19001"))
B19001
# A tibble: 170 x 3
   name      label                  concept                                     
   <chr>     <chr>                  <chr>                                       
 1 B19001_0~ Estimate!!Total        HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN ~
 2 B19001_0~ Estimate!!Total!!Less~ HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN ~
 3 B19001_0~ Estimate!!Total!!$10,~ HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN ~
 4 B19001_0~ Estimate!!Total!!$15,~ HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN ~
 5 B19001_0~ Estimate!!Total!!$20,~ HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN ~
 6 B19001_0~ Estimate!!Total!!$25,~ HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN ~
 7 B19001_0~ Estimate!!Total!!$30,~ HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN ~
 8 B19001_0~ Estimate!!Total!!$35,~ HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN ~
# ... with 162 more rows
Analyzing US Census Data in R

ACS variable structure

Anatomy of an ACS variable B19001_002E:

  • B: refers to base table. Other prefixes: C, DP, S.
  • 19001: the table ID
  • 002: the variable code within the table
  • E: refers to estimate.

    • optional in tidycensus functions, which return both E and M for each variable.
Analyzing US Census Data in R

Let's practice!

Analyzing US Census Data in R

Preparing Video For Download...