Skip to contents

The psrccensus package allows R users at PSRC to download, summarize, and visualize Census, ACS, and PUMS data on common PSRC Census geographies.

Some of the Census, ACS, and PUMS data can be found in our Elmer database: see the internal wiki for more information.

You would want to use psrccensus as opposed to Elmer if: you are working in R, you need a table not in Elmer, and/or you would like a formatted table or map to be produced.

Primary Functions

The three most important functions are:

To use psrccensus, you first will need to get an API key.

Set up your API Key

A key is required to access the Census API. If you haven’t done this before, you should set your Census API Key as an environment variable or store it in your .Renviron file.

Obtain a Census API key here: https://api.census.gov/data/key_signup.html.

There are two methods to set your key:

  1. Once you run Sys.setenv() on the Census API Key you will only need to run Sys.getenv().

    ## 
    #Sys.setenv(CENSUS_API_KEY = 'PUT YOUR KEY HERE')
    Sys.getenv("CENSUS_API_KEY")
  2. An alternative method is to install the key in your .Renviron File for repeated use. This is done via the tidycensus package. The benefit is that you would not have to call Sys.getenv() everytime you run your script or other scripts using psrccensus or tidycensus.

    # first time, run once in console. Then restart R
    tidycensus::census_api_key('your api key', install = TRUE)

Next you need to decide what tables you would like to download and summarize. This is the hardest part because you have to find the correct table code, decide on geography, and which years.

Finding Tables and their Variables

One helpful website for finding the tables on a topic from the ACS and Census is: https://censusreporter.org/

Many of our frequently used Census/ACS/PUMS tables are nicely described in our wiki. Note that Census table names in Elmer are given a two character code such as “H2”. In psrccensus, to be consistent with the tidycensus package, codes must be padded with zeroes so that “H2” becomes “H002”.

Which variables are available in which year in ACS and Census?

The 2020 Census data differs from the 2010 Census datasets. Changes to 2020 Census datasets: https://www2.census.gov/programs-surveys/decennial/2020/program-management/2010_20_data_product_release_dates.pdf

Generally, ACS 1-year data are available down for geographies with populations of 65,000 or more, so you can easily get 1-year data for counties or the region, for example. Once you want to go down to the tract-level, 5-year ACS data is more appropriate. Decennial Census data is available down to the block level.

Functions currently in psrccensus will only return data in Washington State at the county, tract, MSA, and place levels. To access other geographies, consider using tidycensus directly.

Get Data

View the Get Data vignette (under Articles) on how to use the primary functions.

View the Calculate PUMS Summaries vignette (under Articles) on learn how to create aggregations of PUMS data for the region.