Skip to content

Commit 7da017e

Browse files
refactor: IPD 2021 script update (#3)
* ipd review * refactor: changed low_pop_tracts vector * refactor: edited ipd script * refactor: added fields to ipd output * style: removed excess code * refactor: renamed vars to match previous exports * added summary tables and file exports * chore: deleted python folder * fix: environment variables * fix: moe calculations - removes the racial minority estimated MOE, which needs to be replaced by variance replicates * fix: adds back variance replicates for MOE calc of RM indicator * fix: add input settings at top of script * fix: remove white population vars as unused * chore: documentation --------- Co-authored-by: Michael Ruane <mruane@dvrpc.org>
1 parent c40a90d commit 7da017e

4 files changed

Lines changed: 307 additions & 528 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# environment variables
2-
.env
2+
.env
33
.Renviron
44

55
# Output files
@@ -46,3 +46,4 @@ rsconnect/
4646
/metadocumentation
4747
/compare_2015
4848
/compare_2016
49+
/data

README.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ This project automates DVRPC's Indicators of Potential Disadvantage (IPD) analys
44

55
## Getting the Code and Software
66

7-
1. Clone the repository.
7+
1. Clone the repository.
88
2. Download and install R from https://www.r-project.org/
99
3. Download and install R Studio from https://www.rstudio.com/products/rstudio/#Desktop
1010

11-
## Installing Package Dependencies
11+
## Installing Package Dependencies
1212

13-
The R script has the following dependencies:
13+
The R script has the following dependencies:
1414

1515
- plyr
1616
- here
@@ -22,32 +22,33 @@ The R script has the following dependencies:
2222
- dplyr
2323
- descr
2424

25-
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
25+
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
2626
`Error in library (name_of_package) : there is no package called 'name_of_package'`.
2727

28-
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).
28+
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).
2929

3030
## Updating the Script for a New 5-Year Dataset
3131

3232
If you are running the code against a newly released 5-year ACS dataset, do the following:
3333

34-
1. Make a copy of the latest .R file (e.g. script-2019.R) and rename it for the year you are working on. (This is to ensure that any schema changes for a particular 5-year dataset are kept with the code for that set.)
35-
2. Adjust the value for the `ipd_year` variable (to be the end year of the dataset).
34+
1. Update the `ipd_year` in the `ipd.r` to be the end year of the dataset.
35+
2. Update the `output_dir` with the output location for the files.
3636
3. Verify the field names (listed under the `# Fields` section). Follow the link provided to check the schema for that dataset.
3737

3838
## Running the Code
3939

40-
1. Open RStudio.
40+
1. Open RStudio.
4141
2. Open the R file (File -> Open File)
42-
3. Run the code by clicking the Source button or Ctrl+A followed by Ctrl+Enter.
43-
44-
If you see an error about packages not being installed, see [Installing Package Dependencies](#installing-package-dependencies) above.
42+
3. Run the code by clicking the Source button or Ctrl+A followed by Ctrl+Enter.
43+
44+
If you see an error about packages not being installed, see [Installing Package Dependencies](#installing-package-dependencies) above.
4545

4646
Please provide your own API Key (this is required for the `tidycensus` package, not the Census API), you may get another one [here](https://api.census.gov/data/key_signup.html).
4747

48-
### Outputs
48+
### Outputs
4949

5050
After the code has finished, outputs are saved in the /outputs subdirectory of where you cloned the repository on your local machine, including:
51+
5152
- ipd.csv: tract-level statistics and scores for IPD's nine indicators
5253
- ipd.shp: spatial version of ipd.csv
5354
- breaks_by_indicator.csv: bin breaks by indicator
@@ -56,5 +57,6 @@ After the code has finished, outputs are saved in the /outputs subdirectory of w
5657
- mean_by_county.csv: population-weighted county means by indicator
5758

5859
## Additional Information
59-
- [documentation/discussion.pdf](https://github.com/dvrpc/ipd/blob/master/documentation/discussion.pdf) shows the essential math required to compute IPD scores.
60+
61+
- [documentation/discussion.pdf](https://github.com/dvrpc/ipd/blob/master/documentation/discussion.pdf) shows the essential math required to compute IPD scores.
6062
- [documentation/script_reference.pdf](https://github.com/dvrpc/ipd/blob/master/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.

documentation/variables.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ older_adults_universe,S0101_C01_001,S0101_C01_001,S0101_C01_001,S0101_C01_001,S0
2121
older_adults_count,DP05_0025E,DP05_0025E,DP05_0025E,S0101_C01_030,S0101_C01_030,S0101_C01_030,S0101_C01_030
2222
older_adults_percent,S0101_C02_028,S0101_C02_028,S0101_C02_030,S0101_C02_030,S0101_C02_030,S0101_C02_030,S0101_C02_030
2323
racial_minority_universe,B02001_001,B02001_001,B02001_001,B02001_001,B02001_001,B02001_001,B02001_001
24-
racial_minority_count,B02001_002,B02001_002,B02001_002,B02001_002,B02001_002,B02001_002,B02001_002
24+
racial_minority_count,B02001_002,B02001_002,B02001_002,B02001_002,B02001_002,B02001_002,B02001_003...B02001_008
2525
racial_minority_percent,NA,NA,NA,NA,NA,NA,NA
2626
youth_universe,B03002_001,B03002_001,B03002_001,B03002_001,B03002_001,B03002_001,B03002_001
2727
youth_count,B09001_001,B09001_001,B09001_001,B09001_001,B09001_001,B09001_001,B09001_001

0 commit comments

Comments
 (0)