To clone the repo:
-
cd desired_directory
-
git clone
the SSH clone url
To run the code on your local machine:
-
Get an application token from "https://support.socrata.com/hc/en-us/articles/210138558-Generating-an-App-Token"
-
Enter the application token on line 2 of
get_dept_data/hand/config.yaml
next to 'app_token:' -
Set your working directory to the root of the project folder - In Rstudio console:
setwd("../policing_related_rcts")
-
Confirm your working directory is at the root of the project directory - In Rstudio console:
getwd()
-
Singular task(s)
- Manually
- In Rstudio console,
setwd("task-name"); source("src/task-name.r")
Right now the tasks should be run in the following order:
- get_dept_data
- clean_dept_data
- aggregate_dept_data
- run_power_calculations
How to add/use data for another department:
Assuming you are adding data for the philadelphia police department and abbreviating the department name to ppd
To get data for another police department:
-
Add "ppd" to the list of departments in get_dept_data/hand/config.yaml
-
Copy and rename one of the get_dept_data/R/get_x_data_functions.R files as get_ppd_data_functions.R
-
Rename and edit
get_x_data()
andget_x_crime_data()
in get_ppd_data_functions.R as needed to make sure you're getting the right data -
Add
source(file.path("R", "get_ppd_data_functions.R"))
to get_dept_data/src/get_dept_data.R
To clean data for another police department:
-
Add "ppd" to the list of departments in clean_dept_data/hand/config.yaml
-
Copy, rename, and edit
clean_x_data()
andcreate_p1_vio_indicator_x()
toclean_ppd_data()
andcreate_p1_vio_indicator_ppd()
in clean_dept_data_functions.R.
To include data for another police department in aggregation:
- Add "ppd" to the list of departments in aggregate_dept_data/hand/config.yaml
To commit to this repo:
- Please first read https://chris.beams.io/posts/git-commit/
Brief notes to better understand quirks of the different datasets discovered while cleaning and helpful when creating crime indicators:
- NYPD
- has two fields that can be used to create crime indicators -
pd_cd
andofns_desc
- rather than using
pd_cd
, we use the much simpler (and more conservative)ofns_desc
- CPD
- we use a dataset from Chicago's open data portal linking Illinois UCR codes to FBI UCR codes
- LAPD
- we use the
crm_cd_1
field and, in cases where it is missing, thecrm_cd
field
- DPD
- we focus on codes belonging to part 1
- the one exception is our inclusion of all arson codes regardless of part designation
- all ucr data is missing for 2019, so used the list of ucrcodes we created to come up with a list of nibrs codes that are roughly equivalent