Search code examples
rtidycensus

R Tidy Census - Variable for Voters 18+


I have been trying to find a variable on the Tidy Census’ latest American Community Survey (ACS) variable list.

The one I’m looking for would be for all voters aged 18 and up. I have yet to find it in the list. Even if I have to combine a couple variables to make it work, that’s fine too.

I search for relevant keywords related to age, but have yet to find anything. Variables that appear with “18 years and over” have a greater specificity than what I am looking for. I may be missing something though; I’m new to Tidy Census.

Help would be greatly appreciated!


Solution

  • Finding Census variables is difficult. Start here: https://data.census.gov/table?q=ACS

    In table S0101 under labels there is a selected age categories variable named 18 years and over.

    Searched those those keywords and found this long list. https://api.census.gov/data/2019/acs/acs1/subject/variables/

    Where we find variable "S0101_C01_026".

    ["S0101_C01_026E","Estimate!!Total!!Total population!!SELECTED AGE CATEGORIES!!18 years and over","AGE AND SEX"],

    Then we can get that variable:

    county_data<-get_acs(geography = "county", 
                    variables = "S0101_C01_026",
                    cache_table=TRUE,
                    year=2021)
    

    county_data

    # A tibble: 3,221 × 5
       GEOID NAME                     variable      estimate   moe
       <chr> <chr>                    <chr>            <dbl> <dbl>
     1 01001 Autauga County, Alabama  S0101_C01_026    44438   122
     2 01003 Baldwin County, Alabama  S0101_C01_026   178105    NA
     3 01005 Barbour County, Alabama  S0101_C01_026    19995    28
     4 01007 Bibb County, Alabama     S0101_C01_026    17800    44
     5 01009 Blount County, Alabama   S0101_C01_026    45201    75