Demographics

This page is still under development - new content may be added and existing content may change at any time without notice

Depending on what demographics data sources and software you decide to use, the methods needed to combine, overlay, or compare with the data you are interested in may vary. See the Demographics Data section of the Data Collection page for general guidance and things to consider when using demographics data. See below for step by step guidance on how to download and compare demographics data to point, line, and polygon data types programmatically using R or Python, or manually using ESRI tools.

Important Reminders Before You Dive In

Data are NOT people - We need to use these data to get a better understanding of what’s going on in our communities, but the data (at best) only represent a sample of the community’s population and in no way reflect everyone or their lived experiences.

There’s no such thing as “equity data” - how we use data, interpret it, and act on what we learn makes our use equitable (or not). Simply including demographics data in your project’s analysis or data products does not make those resources equitable - to operationalize equity we need to take actions and make decisions in ways to advance equitable outcomes.

The data you’re using has limitations, be sure you know what they are before moving forward - as discussed on the Data Collection page, all data have limitations, and that is particularly true for demographics data. Be sure you have a clear and comprehensive understanding of the limitations that apply to the specific datasets you’re using so you can collect and eventually process and analyze those data in ways that are appropriate.

R Data Integration Example

R1 is a free software environment for statistical computing and graphics (Training Resources). RStudio is an integrated development environment (IDE) that includes is a set of tools and user interfaces built to help you be more productive with R and Python.

Setup

If you haven’t already, you will need to install R and RStudio. Water Boards staff should be able to do so through the Software Center. Also see step by step installation instructions for outside of the Software Center environment.

If you will be using U.S. Census data regularly and will be accessing and analyzing it programmatically (e.g. using R or Python), you will also need to Request a U.S. Census Data API Key.

Download Packages

R Packages / Libraries are extensions to the R statistical programming language that contain code, data, and documentation in a standardized collection format that can be installed by users of R.

Install Packages

You must install any packages you will use on your computer before you can load them. You only need to install a package once; if you have already installed the below packages you can skip this step and proceed to the Load Packages step.

1install.packages("here")
2install.packages("tidyverse")
3install.packages("ggplot2")
4install.packages("tidycensus")
5install.packages("sf")
6install.packages("patchwork")
1
The here package enables easy, shareable and reproducible file referencing in project-oriented workflows. In contrast to using setwd(), which is fragile and dependent on the way you organize your files, here uses the top-level directory of a project to easily build paths to files. Package Documentation
2
The tidyverse package installs all packages in the tidyverse at once, including: ggplot2, dplyr, tidyr, among others. Package Documentation
3
The ggplot2 package is used to create graphics and data visualizations. Package Documentation
4
The tidycensus package allows users to interface with the US Census Bureau’s decennial Census and five-year American Community APIs and return tidyverse-ready data frames. Package Documentation
5
The sf package provides access to simple features in R so users can work with geographic vectors. Package Documentation
6
The patchwork package is an extension of the ggplot2 package, designed to simplify the process of combining multiple plots into a single layout. Package Documentation

Load Packages

You must load all packages you will use for an analysis before each use.

library(here) 
library(ggplot2) 
library(tidyverse) 
library(tidycensus) 
library(sf) 
library(patchwork)

Collecting Data

Activate Census API Key

7census_api_key(" ")
7
modify code to pull from api key located in file to increase security
  • geographies

  • last data update

  • age categories

Take some time to review the Concept and Labels in the table -

summary_var = "P2_001N" # Total population

Common tables to use in sources

Data Prep & Use

Points

Lines

Polygons

Data Interpretation

Other R Examples and Resources

Python Data Integration Example

Python is a….

ESRI Data Integration Example

ESRI is a….

Footnotes

  1. The bulk of content in this section has been informed by, adapted or directly pulled from DataMade guidance, resources (e.g., Analysis Steps).↩︎