This project automates DVRPC's Indicators of Potential Disadvantage (IPD) analysis, including data download, processing, and export. For more on IPD analysis, see Equity Analysis for the Greater Philadelphia Region v2.0.
- Clone the repository.
- Download and install R from https://www.r-project.org/
- Download and install R Studio from https://www.rstudio.com/products/rstudio/#Desktop
The R script has the following dependencies:
- plyr
- here
- sf
- summarytools
- tidycensus
- tidyverse
- tigris
- dplyr
- descr
If you have not previously installed the dependencies, you will need to do so. If you try to run the script without installing the packages, you will get an error message like
Error in library (name_of_package) : there is no package called 'name_of_package'
.
Install each package from R Studio's console (typically at the bottom of the screen in R Studio) with the command install.packages('name_of_package')
(include the quotation marks).
If you are running the code against a newly released 5-year ACS dataset, do the following:
- Update the
ipd_year
in theipd.r
to be the end year of the dataset. - Update the
output_dir
with the output location for the files. - Verify the field names (listed under the
# Fields
section). Follow the link provided to check the schema for that dataset.
- Open RStudio.
- Open the R file (File -> Open File)
- Run the code by clicking the Source button or Ctrl+A followed by Ctrl+Enter.
If you see an error about packages not being installed, see Installing Package Dependencies above.
Please provide your own API Key (this is required for the tidycensus
package, not the Census API), you may get another one here.
After the code has finished, outputs are saved in the /outputs subdirectory of where you cloned the repository on your local machine, including:
- ipd.csv: tract-level statistics and scores for IPD's nine indicators
- ipd.shp: spatial version of ipd.csv
- breaks_by_indicator.csv: bin breaks by indicator
- counts_by_indicator.csv: census tract counts by bin and indicator
- summary_by_indicator.csv: basic summary stats by indicator
- mean_by_county.csv: population-weighted county means by indicator
- documentation/discussion.pdf shows the essential math required to compute IPD scores.
- documentation/script_reference.pdf is a companion document to the script and explains the way the script downloads data and implements IPD analysis, code chunk by code chunk.