Last updated: 2024-05-27

Checks: 7 0

Knit directory: PODFRIDGE/

This reproducible R Markdown analysis was created with workflowr (version 1.7.1). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20230302) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 332d5a2. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Untracked files:
    Untracked:  Rplots.pdf

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/CODIS_DB_composition.Rmd) and HTML (docs/CODIS_DB_composition.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 332d5a2 hcvw 2024-05-27 wflow_publish(c(“analysis/CODIS_DB_composition.Rmd”, “analysis/final_equation.Rmd”,

# load necessary libraries
library(readr)
library(tidycensus)
library(tidyverse)
library(ggplot2)
library(viridis)
library(knitr)
# load prison data
prison_data = read.csv("./data/populations_states.csv")

# load CODIS data
codis_data = read.csv("./data/CODIS_data.csv")

# only get data from 2022
prison_data$year = substring(prison_data$date,1,4)
prison_data_2022 = prison_data[which(prison_data$year == "2022"),]
prison_data_2022 = prison_data_2022[!duplicated(prison_data_2022[,c('state')]),]

Loading census data for each state:

P003001 is the total population and P003003 is the total Black population

us_state_density <- get_decennial(
  geography = "state",
  variables = c(all = "P1_002N",white = "P1_003N",black = "P1_004N"),
  year = 2020,
  geometry = TRUE,
  keep_geo_vars = TRUE
) 
us_state_density = spread(us_state_density, variable, value)
us_state_density$pb = us_state_density$black / us_state_density$all
us_state_density$pw = us_state_density$white / us_state_density$all

us_state_density$state = us_state_density$NAME.x
us_state_density = merge(us_state_density, prison_data_2022, by = "state")
us_state_density$pb_carc = us_state_density$incarcerated_black / us_state_density$incarcerated_total
us_state_density$pw_carc = us_state_density$incarcerated_white / us_state_density$incarcerated_total

us_state_density = merge(us_state_density, codis_data, by = "state")
us_state_density$black_profiles = us_state_density$pb_carc * us_state_density$arrestee_profiles
us_state_density$white_profiles = us_state_density$pw_carc * us_state_density$arrestee_profiles

us_state_density = us_state_density %>%
  tigris::shift_geometry()

Percent of prison population that is Black

ggplot() +
  geom_sf(data = us_state_density, aes(fill = us_state_density$pb_carc),color = NA) + 
  theme_void(base_size = 11) + 
  scale_fill_viridis(option = "magma", direction = -1)+
  labs(fill = "") + 
  geom_sf(data = us_state_density$geometry, color = "black",lwd = 0.1,alpha = 0) 

Difference between percent of prison population that is Black and percent of general population that is Black

ggplot() +
  geom_sf(data = us_state_density, aes(fill = us_state_density$pb_carc - us_state_density$pb),color = NA) + 
  theme_void(base_size = 11) + 
  scale_fill_viridis(option = "magma", direction = -1)+
  labs(fill = "") + 
  geom_sf(data = us_state_density$geometry, color = "black",lwd = 0.1,alpha = 0) 

Number of people in CODIS databse per state

ggplot() +
  geom_sf(data = us_state_density, aes(fill = us_state_density$offender_profiles),color = NA) + 
  theme_void(base_size = 11) + 
  scale_fill_viridis(option = "magma", direction = -1)+
  labs(fill = "") + 
  geom_sf(data = us_state_density$geometry, color = "black",lwd = 0.1,alpha = 0) 

Number of Black people in CODIS databse per state

ggplot() +
  geom_sf(data = us_state_density, aes(fill = us_state_density$black_profiles),color = NA) + 
  theme_void(base_size = 11) + 
  scale_fill_viridis(option = "magma", direction = -1)+
  labs(fill = "") + 
  geom_sf(data = us_state_density$geometry, color = "black",lwd = 0.1,alpha = 0) 

Probability of being in CODIS by race and state

State P(Black individual in CODIS) P(white individual in CODIS)
Alabama 0.0415 0.0144
Arizona 0.0305 0.0062
Arkansas 0.0696 0.021
California 0.1281 0.0123
Colorado 0.2717 0.0372
Connecticut 0 0
Delaware 0 0
District of Columbia 0 0
Florida 0.0928 0.02
Georgia 0 0
Idaho 0 0
Illinois 3e-04 0
Indiana 0.0685 0.0166
Iowa 0 0
Kansas 0.234 0.043
Kentucky 0 0
Louisiana 0.2274 0.0649
Maine 0 0
Maryland 0.0224 0.0043
Massachusetts 0 0
Michigan NA 0.0117
Minnesota 0 0
Mississippi 0.0047 0.0019
Missouri 0.0337 0.0095
Montana 0 0
Nebraska 0 0
Nevada 0.1594 0.0401
New Hampshire 0 0
New Jersey 0.0127 0.0011
New Mexico 0.1285 0.0528
New York 0 0
North Carolina 0.0168 0.0045
North Dakota 0.1537 0.032
Ohio 0.1162 0.0221
Oklahoma 0.0124 0.0026
Oregon 0 0
Pennsylvania 0 0
Rhode Island 0.0037 2e-04
South Carolina 0.0346 0.0087
South Dakota 0.2681 0.0438
Tennessee 0.0608 0.0178
Texas 0.0178 0.0045
Utah 0.0128 0.0016
Vermont 0.019 0.0027
Virginia 0.0014 3e-04
Washington 0 0
West Virginia 0 0
Wisconsin 0.0303 0.0031
Wyoming 0 0
Alaska 0.2379 0.0488
Hawaii 0 0

sessionInfo()
R version 4.3.1 (2023-06-16)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.3 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so;  LAPACK version 3.10.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: America/New_York
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] knitr_1.46        viridis_0.6.4     viridisLite_0.4.2 lubridate_1.9.2  
 [5] forcats_1.0.0     stringr_1.5.0     dplyr_1.1.2       purrr_1.0.2      
 [9] tidyr_1.3.0       tibble_3.2.1      ggplot2_3.5.0     tidyverse_2.0.0  
[13] tidycensus_1.4.4  readr_2.1.4       workflowr_1.7.1  

loaded via a namespace (and not attached):
 [1] gtable_0.3.3       xfun_0.44          bslib_0.5.1        tigris_2.0.3      
 [5] processx_3.8.4     callr_3.7.3        tzdb_0.4.0         vctrs_0.6.5       
 [9] tools_4.3.1        ps_1.7.6           generics_0.1.3     curl_5.0.2        
[13] proxy_0.4-27       fansi_1.0.6        highr_0.10         pkgconfig_2.0.3   
[17] KernSmooth_2.23-22 uuid_1.1-1         lifecycle_1.0.4    farver_2.1.1      
[21] compiler_4.3.1     git2r_0.33.0       munsell_0.5.0      getPass_0.2-4     
[25] httpuv_1.6.11      htmltools_0.5.6    class_7.3-22       sass_0.4.7        
[29] yaml_2.3.7         later_1.3.1        pillar_1.9.0       crayon_1.5.2      
[33] jquerylib_0.1.4    whisker_0.4.1      classInt_0.4-9     cachem_1.0.8      
[37] tidyselect_1.2.0   rvest_1.0.3        digest_0.6.33      stringi_1.7.12    
[41] sf_1.0-14          labeling_0.4.2     rprojroot_2.0.3    fastmap_1.1.1     
[45] grid_4.3.1         colorspace_2.1-0   cli_3.6.2          magrittr_2.0.3    
[49] utf8_1.2.4         e1071_1.7-13       withr_3.0.0        scales_1.3.0      
[53] promises_1.2.1     rappdirs_0.3.3     timechange_0.2.0   rmarkdown_2.25    
[57] httr_1.4.7         gridExtra_2.3      hms_1.1.3          evaluate_0.21     
[61] rlang_1.1.3        Rcpp_1.0.11        glue_1.7.0         DBI_1.1.3         
[65] xml2_1.3.5         rstudioapi_0.15.0  jsonlite_1.8.8     R6_2.5.1          
[69] fs_1.6.3           units_0.8-3