diff --git a/code/00_load_dependencies.R b/code/00_load_dependencies.R index 291af3f..2805836 100644 --- a/code/00_load_dependencies.R +++ b/code/00_load_dependencies.R @@ -33,4 +33,4 @@ if(length(new.packages)) install.packages(new.packages) lapply(list.of.packages, require, character.only = TRUE) # remove created variables for packages -rm(list.of.packages,new.packages) \ No newline at end of file +rm(list.of.packages,new.packages) diff --git a/code/01_city_demo_diversity.Rmd b/code/01_city_demo_diversity.Rmd index 3cd23fa..943e537 100644 --- a/code/01_city_demo_diversity.Rmd +++ b/code/01_city_demo_diversity.Rmd @@ -3,7 +3,7 @@ title: "01_city_demo_diversity_metric_new" output: html_document --- -```{r setup} +```{r} # R version # using PUMS 2016-2020 5 Year Labor Force demographics @@ -13,38 +13,112 @@ output: html_document # https://webapps.dol.gov/dolfaq/go-dol-faq.asp?faqid=111&faqsub=Labor+Force&faqtop=Statistics&topicid=6 # # ***FIRST***: load libraries from `00_load_dependencies.R` +options(scipen = 999) ``` ```{r} -# source("envs.R") . -options(scipen = 999) # read in data from mdat pums ----------- -# 2020 5-Year +# 2018, 2019, 2020, 2021 5-Year # ----- ***TO DO***: GET NEW DATA ----- -t_18 <- fromJSON(paste0('https://api.census.gov/data/2018/acs/acs5/pums?get=PWGTP,PWGTP,RAC1P,SEX,ESR,HISP&ucgid=7950000US3603701,7950000US3603702,7950000US3603703,7950000US3603704,7950000US3603705,7950000US3603706,7950000US3603707,7950000US3603708,7950000US3603709,7950000US3603710,7950000US3603801,7950000US3603802,7950000US3603803,7950000US3603804,7950000US3603805,7950000US3603806,7950000US3603807,7950000US3603808,7950000US3603809,7950000US3603810,7950000US3603901,7950000US3603902,7950000US3603903,7950000US3604001,7950000US3604002,7950000US3604003,7950000US3604004,7950000US3604005,7950000US3604006,7950000US3604007,7950000US3604008,7950000US3604009,7950000US3604010,7950000US3604011,7950000US3604012,7950000US3604013,7950000US3604014,7950000US3604015,7950000US3604016,7950000US3604017,7950000US3604018,7950000US3604101,7950000US3604102,7950000US3604103,7950000US3604104,7950000US3604105,7950000US3604106,7950000US3604107,7950000US3604108,7950000US3604109,7950000US3604110,7950000US3604111,7950000US3604112,7950000US3604113,7950000US3604114&key=', Sys.getenv("KEY"))) +vars = "PWGTP,RAC1P,SEX,ESR,HISP" +geographies=c("7950000US3603701","7950000US3603702","7950000US3603703","7950000US3603704","7950000US3603705","7950000US3603706","7950000US3603707","7950000US3603708","7950000US3603709","7950000US3603710","7950000US3603801","7950000US3603802","7950000US3603803","7950000US3603804","7950000US3603805","7950000US3603806","7950000US3603807","7950000US3603808","7950000US3603809","7950000US3603810","7950000US3603901","7950000US3603902","7950000US3603903","7950000US3604001","7950000US3604002","7950000US3604003","7950000US3604004","7950000US3604005","7950000US3604006","7950000US3604007","7950000US3604008","7950000US3604009","7950000US3604010","7950000US3604011","7950000US3604012","7950000US3604013","7950000US3604014","7950000US3604015","7950000US3604016","7950000US3604017","7950000US3604018","7950000US3604101","7950000US3604102","7950000US3604103","7950000US3604104","7950000US3604105","7950000US3604106","7950000US3604107","7950000US3604108","7950000US3604109","7950000US3604110","7950000US3604111","7950000US3604112","7950000US3604113","7950000US3604114") +dataset = "acs/acs5/pums" #american community survey, 5 year, public microdata sample (PUMS) ``` ```{r} -# ----- GETTING NEW DATA (2019) ----- -t_19 <- fromJSON(paste0('https://api.census.gov/data/2019/acs/acs5/pums?get=PWGTP,PWGTP,RAC1P,SEX,ESR,HISP&ucgid=7950000US3603701,7950000US3603702,7950000US3603703,7950000US3603704,7950000US3603705,7950000US3603706,7950000US3603707,7950000US3603708,7950000US3603709,7950000US3603710,7950000US3603801,7950000US3603802,7950000US3603803,7950000US3603804,7950000US3603805,7950000US3603806,7950000US3603807,7950000US3603808,7950000US3603809,7950000US3603810,7950000US3603901,7950000US3603902,7950000US3603903,7950000US3604001,7950000US3604002,7950000US3604003,7950000US3604004,7950000US3604005,7950000US3604006,7950000US3604007,7950000US3604008,7950000US3604009,7950000US3604010,7950000US3604011,7950000US3604012,7950000US3604013,7950000US3604014,7950000US3604015,7950000US3604016,7950000US3604017,7950000US3604018,7950000US3604101,7950000US3604102,7950000US3604103,7950000US3604104,7950000US3604105,7950000US3604106,7950000US3604107,7950000US3604108,7950000US3604109,7950000US3604110,7950000US3604111,7950000US3604112,7950000US3604113,7950000US3604114&key=', Sys.getenv("KEY"))) +get_acs <- function(request, year) { + df = data.frame() + for (i in 1:length(geographies)) { + geography = geographies[i] + print(geography) + + request = paste( + "https://api.census.gov/data/", + year, + "/", + dataset, + "?get=", + vars, + "&ucgid=", + geography, + sep = '' + ) + + r <- GET(request) # library(httr) + print(r$status_code) + content = content(r) + + p = length(content[[1]]) + n = length(content) - 1 + + M = matrix(unlist(content), ncol = p, byrow = TRUE) + tmp = data.frame(M[2:nrow(M), ]) + colnames(tmp) = M[1, ] + + df = rbind(df, tmp) + } + return(df) +} ``` ```{r} -# ----- GETTING NEW DATA (2020) ----- -t_20 <- fromJSON(paste0('https://api.census.gov/data/2020/acs/acs5/pums?get=PWGTP,PWGTP,RAC1P,SEX,ESR,HISP&ucgid=7950000US3603701,7950000US3603702,7950000US3603703,7950000US3603704,7950000US3603705,7950000US3603706,7950000US3603707,7950000US3603708,7950000US3603709,7950000US3603710,7950000US3603801,7950000US3603802,7950000US3603803,7950000US3603804,7950000US3603805,7950000US3603806,7950000US3603807,7950000US3603808,7950000US3603809,7950000US3603810,7950000US3603901,7950000US3603902,7950000US3603903,7950000US3604001,7950000US3604002,7950000US3604003,7950000US3604004,7950000US3604005,7950000US3604006,7950000US3604007,7950000US3604008,7950000US3604009,7950000US3604010,7950000US3604011,7950000US3604012,7950000US3604013,7950000US3604014,7950000US3604015,7950000US3604016,7950000US3604017,7950000US3604018,7950000US3604101,7950000US3604102,7950000US3604103,7950000US3604104,7950000US3604105,7950000US3604106,7950000US3604107,7950000US3604108,7950000US3604109,7950000US3604110,7950000US3604111,7950000US3604112,7950000US3604113,7950000US3604114&key=', Sys.getenv("KEY"))) +# ---- GETTING NEW DATA (2018) ---- +request = paste0('https://api.census.gov/data/2018/acs/acs5/pums?get=PWGTP,RAC1P,SEX,ESR,HISP&ucgid=7950000US3603701,7950000US3603702,7950000US3603703,7950000US3603704,7950000US3603705,7950000US3603706,7950000US3603707,7950000US3603708,7950000US3603709,7950000US3603710,7950000US3603801,7950000US3603802,7950000US3603803,7950000US3603804,7950000US3603805,7950000US3603806,7950000US3603807,7950000US3603808,7950000US3603809,7950000US3603810,7950000US3603901,7950000US3603902,7950000US3603903,7950000US3604001,7950000US3604002,7950000US3604003,7950000US3604004,7950000US3604005,7950000US3604006,7950000US3604007,7950000US3604008,7950000US3604009,7950000US3604010,7950000US3604011,7950000US3604012,7950000US3604013,7950000US3604014,7950000US3604015,7950000US3604016,7950000US3604017,7950000US3604018,7950000US3604101,7950000US3604102,7950000US3604103,7950000US3604104,7950000US3604105,7950000US3604106,7950000US3604107,7950000US3604108,7950000US3604109,7950000US3604110,7950000US3604111,7950000US3604112,7950000US3604113,7950000US3604114&key=', Sys.getenv("KEY")) +year = "2018" +t_18 <- get_acs(request, year) ``` ```{r} -convert_df <- function(t) { - df=t - df[1,1:ncol(df)] - df<-as.data.frame(df[1:nrow(df), 1:ncol(df)]) - names(df)<-t[1,1:ncol(t)] - df=df[-1,-1] -} -df_18 = convert_df(t_18) -df_19 = convert_df(t_19) -df_20 = convert_df(t_20) +# ----- GETTING NEW DATA (2019) ---- +request = paste0('https://api.census.gov/data/2019/acs/acs5/pums?get=PWGTP,RAC1P,SEX,ESR,HISP&ucgid=7950000US3603701,7950000US3603702,7950000US3603703,7950000US3603704,7950000US3603705,7950000US3603706,7950000US3603707,7950000US3603708,7950000US3603709,7950000US3603710,7950000US3603801,7950000US3603802,7950000US3603803,7950000US3603804,7950000US3603805,7950000US3603806,7950000US3603807,7950000US3603808,7950000US3603809,7950000US3603810,7950000US3603901,7950000US3603902,7950000US3603903,7950000US3604001,7950000US3604002,7950000US3604003,7950000US3604004,7950000US3604005,7950000US3604006,7950000US3604007,7950000US3604008,7950000US3604009,7950000US3604010,7950000US3604011,7950000US3604012,7950000US3604013,7950000US3604014,7950000US3604015,7950000US3604016,7950000US3604017,7950000US3604018,7950000US3604101,7950000US3604102,7950000US3604103,7950000US3604104,7950000US3604105,7950000US3604106,7950000US3604107,7950000US3604108,7950000US3604109,7950000US3604110,7950000US3604111,7950000US3604112,7950000US3604113,7950000US3604114&key=', Sys.getenv("KEY")) +year = "2019" +t_19 <- get_acs(request, year) +``` + +```{r} +# ----- GETTING NEW DATA (2020) ---- +request = paste0('https://api.census.gov/data/2020/acs/acs5/pums?get=PWGTP,RAC1P,SEX,ESR,HISP&ucgid=7950000US3603701,7950000US3603702,7950000US3603703,7950000US3603704,7950000US3603705,7950000US3603706,7950000US3603707,7950000US3603708,7950000US3603709,7950000US3603710,7950000US3603801,7950000US3603802,7950000US3603803,7950000US3603804,7950000US3603805,7950000US3603806,7950000US3603807,7950000US3603808,7950000US3603809,7950000US3603810,7950000US3603901,7950000US3603902,7950000US3603903,7950000US3604001,7950000US3604002,7950000US3604003,7950000US3604004,7950000US3604005,7950000US3604006,7950000US3604007,7950000US3604008,7950000US3604009,7950000US3604010,7950000US3604011,7950000US3604012,7950000US3604013,7950000US3604014,7950000US3604015,7950000US3604016,7950000US3604017,7950000US3604018,7950000US3604101,7950000US3604102,7950000US3604103,7950000US3604104,7950000US3604105,7950000US3604106,7950000US3604107,7950000US3604108,7950000US3604109,7950000US3604110,7950000US3604111,7950000US3604112,7950000US3604113,7950000US3604114&key=', Sys.getenv("KEY")) +year = "2020" +t_20 <- get_acs(request, year) +``` + +```{r} +# ----- GETTING NEW DATA (2021) ---- +request = paste0('https://api.census.gov/data/2021/acs/acs5/pums?get=PWGTP,RAC1P,SEX,ESR,HISP&ucgid=7950000US3603701,7950000US3603702,7950000US3603703,7950000US3603704,7950000US3603705,7950000US3603706,7950000US3603707,7950000US3603708,7950000US3603709,7950000US3603710,7950000US3603801,7950000US3603802,7950000US3603803,7950000US3603804,7950000US3603805,7950000US3603806,7950000US3603807,7950000US3603808,7950000US3603809,7950000US3603810,7950000US3603901,7950000US3603902,7950000US3603903,7950000US3604001,7950000US3604002,7950000US3604003,7950000US3604004,7950000US3604005,7950000US3604006,7950000US3604007,7950000US3604008,7950000US3604009,7950000US3604010,7950000US3604011,7950000US3604012,7950000US3604013,7950000US3604014,7950000US3604015,7950000US3604016,7950000US3604017,7950000US3604018,7950000US3604101,7950000US3604102,7950000US3604103,7950000US3604104,7950000US3604105,7950000US3604106,7950000US3604107,7950000US3604108,7950000US3604109,7950000US3604110,7950000US3604111,7950000US3604112,7950000US3604113,7950000US3604114&key=', Sys.getenv("KEY")) +year = "2021" +t_21 <- get_acs(request, year) +``` + +```{r} +# # source("envs.R") . +# options(scipen = 999) +# # read in data from mdat pums ----------- +# # 2020 5-Year +# # ----- ***TO DO***: GET NEW DATA ----- +# t_18 <- fromJSON(paste0('https://api.census.gov/data/2018/acs/acs5/pums?get=PWGTP,PWGTP,RAC1P,SEX,ESR,HISP&ucgid=7950000US3603701,7950000US3603702,7950000US3603703,7950000US3603704,7950000US3603705,7950000US3603706,7950000US3603707,7950000US3603708,7950000US3603709,7950000US3603710,7950000US3603801,7950000US3603802,7950000US3603803,7950000US3603804,7950000US3603805,7950000US3603806,7950000US3603807,7950000US3603808,7950000US3603809,7950000US3603810,7950000US3603901,7950000US3603902,7950000US3603903,7950000US3604001,7950000US3604002,7950000US3604003,7950000US3604004,7950000US3604005,7950000US3604006,7950000US3604007,7950000US3604008,7950000US3604009,7950000US3604010,7950000US3604011,7950000US3604012,7950000US3604013,7950000US3604014,7950000US3604015,7950000US3604016,7950000US3604017,7950000US3604018,7950000US3604101,7950000US3604102,7950000US3604103,7950000US3604104,7950000US3604105,7950000US3604106,7950000US3604107,7950000US3604108,7950000US3604109,7950000US3604110,7950000US3604111,7950000US3604112,7950000US3604113,7950000US3604114&key=', Sys.getenv("KEY"))) +``` + +```{r} +# # ----- GETTING NEW DATA (2019) ----- +# t_19 <- fromJSON(paste0('https://api.census.gov/data/2019/acs/acs5/pums?get=PWGTP,PWGTP,RAC1P,SEX,ESR,HISP&ucgid=7950000US3603701,7950000US3603702,7950000US3603703,7950000US3603704,7950000US3603705,7950000US3603706,7950000US3603707,7950000US3603708,7950000US3603709,7950000US3603710,7950000US3603801,7950000US3603802,7950000US3603803,7950000US3603804,7950000US3603805,7950000US3603806,7950000US3603807,7950000US3603808,7950000US3603809,7950000US3603810,7950000US3603901,7950000US3603902,7950000US3603903,7950000US3604001,7950000US3604002,7950000US3604003,7950000US3604004,7950000US3604005,7950000US3604006,7950000US3604007,7950000US3604008,7950000US3604009,7950000US3604010,7950000US3604011,7950000US3604012,7950000US3604013,7950000US3604014,7950000US3604015,7950000US3604016,7950000US3604017,7950000US3604018,7950000US3604101,7950000US3604102,7950000US3604103,7950000US3604104,7950000US3604105,7950000US3604106,7950000US3604107,7950000US3604108,7950000US3604109,7950000US3604110,7950000US3604111,7950000US3604112,7950000US3604113,7950000US3604114&key=', Sys.getenv("KEY"))) +``` + +```{r} +# # ----- GETTING NEW DATA (2020) ----- +# t_20 <- fromJSON(paste0('https://api.census.gov/data/2020/acs/acs5/pums?get=PWGTP,PWGTP,RAC1P,SEX,ESR,HISP&ucgid=7950000US3603701,7950000US3603702,7950000US3603703,7950000US3603704,7950000US3603705,7950000US3603706,7950000US3603707,7950000US3603708,7950000US3603709,7950000US3603710,7950000US3603801,7950000US3603802,7950000US3603803,7950000US3603804,7950000US3603805,7950000US3603806,7950000US3603807,7950000US3603808,7950000US3603809,7950000US3603810,7950000US3603901,7950000US3603902,7950000US3603903,7950000US3604001,7950000US3604002,7950000US3604003,7950000US3604004,7950000US3604005,7950000US3604006,7950000US3604007,7950000US3604008,7950000US3604009,7950000US3604010,7950000US3604011,7950000US3604012,7950000US3604013,7950000US3604014,7950000US3604015,7950000US3604016,7950000US3604017,7950000US3604018,7950000US3604101,7950000US3604102,7950000US3604103,7950000US3604104,7950000US3604105,7950000US3604106,7950000US3604107,7950000US3604108,7950000US3604109,7950000US3604110,7950000US3604111,7950000US3604112,7950000US3604113,7950000US3604114&key=', Sys.getenv("KEY"))) +``` + +```{r} +# convert_df <- function(t) { +# df=t +# df[1,1:ncol(df)] +# df<-as.data.frame(df[1:nrow(df), 1:ncol(df)]) +# names(df)<-t[1,1:ncol(t)] +# df=df[-1,-1] +# } +# df_18 = convert_df(t_18) +# df_19 = convert_df(t_19) +# df_20 = convert_df(t_20) ``` ```{r} @@ -71,7 +145,7 @@ recode_df <- function(df) { "9" = "Other"), SEX = recode(SEX, "1" = "Male", "2" = "Female"), - HISP = case_when(HISP != "1" ~ "Hispanic or Latino", + HISP = case_when(HISP != "01" ~ "Hispanic or Latino", # changed from "1" to "01" in 2021 TRUE ~ "Non-Hispanic"), race_ethnicity = case_when(HISP == "Non-Hispanic" ~ race_ethnicity, TRUE ~ "Hispanic or Latino"), @@ -90,9 +164,10 @@ recode_df <- function(df) { ``` ```{r} -df_18_1 <- recode_df(df_18) -df_19_1 <- recode_df(df_19) -df_20_1 <- recode_df(df_20) +df_18_1 <- recode_df(t_18) +df_19_1 <- recode_df(t_19) +df_20_1 <- recode_df(t_20) +df_21_1 <- recode_df(t_21) ``` ```{r} @@ -107,6 +182,7 @@ pw_value <- function(df) { df_18_2 <- pw_value(df_18_1) df_19_2 <- pw_value(df_19_1) df_20_2 <- pw_value(df_20_1) +df_21_2 <- pw_value(df_21_1) ``` ```{r, include=FALSE} @@ -114,15 +190,17 @@ df_20_2 <- pw_value(df_20_1) # should be around 8 million/year sum(as.integer(df_18_1$PWGTP)) sum(as.integer(df_19_1$PWGTP)) -sum(as.integer(df_20_1$PWGTP)) # looking good +sum(as.integer(df_20_1$PWGTP)) +sum(as.integer(df_21_1$PWGTP))# looking good ``` ```{r} # individual level demos ----- # whereas df_[year]_1 is aggregated by total of x demographic -write.csv(df_18_2, '../data/output/city_demo_by-pums_2018.csv', row.names = F) +write.csv(df_18_2, '../data/output/city_demo_by-pums_2018_2.csv', row.names = F) write.csv(df_19_2, '../data/output/city_demo_by-pums_2019.csv', row.names = F) write.csv(df_20_2, '../data/output/city_demo_by-pums_2020.csv', row.names = F) +write.csv(df_21_2, '../data/output/city_demo_by-pums_2021.csv', row.names = F) ``` ```{r} @@ -144,6 +222,7 @@ filter_race <- function(df2) { race_18 <- filter_race(df_18_2) race_19 <- filter_race(df_19_2) race_20 <- filter_race(df_20_2) +race_21 <- filter_race(df_21_2) # ----- ***TO DO***: AGGREGATE, FILTER FOR 2019 & 2020 ----- @@ -159,6 +238,7 @@ filter_gender <- function(df2) { sex_18 <- filter_gender(df_18_2) sex_19 <- filter_gender(df_19_2) sex_20 <- filter_gender(df_20_2) +sex_21 <- filter_gender(df_21_2) ``` ```{r} @@ -174,37 +254,44 @@ get_var <- function(yr, group, demo) { city_female_18 <- get_var(sex_18, sex_18$SEX, "Female") city_female_19 <- get_var(sex_19, sex_19$SEX, "Female") city_female_20 <- get_var(sex_20, sex_20$SEX, "Female") +city_female_21 <- get_var(sex_21, sex_21$SEX, "Female") # male: city_male_18 <- get_var(sex_18, sex_18$SEX, "Male") city_male_19 <- get_var(sex_19, sex_19$SEX, "Male") city_male_20 <- get_var(sex_20, sex_20$SEX, "Male") +city_male_21 <- get_var(sex_21, sex_21$SEX, "Male") # ---- RACE ---- # nh white: city_white_18 <- get_var(race_18, race_18$race_ethnicity, "NH White") city_white_19 <- get_var(race_19, race_19$race_ethnicity, "NH White") city_white_20 <- get_var(race_20, race_20$race_ethnicity, "NH White") +city_white_21 <- get_var(race_21, race_21$race_ethnicity, "NH White") # nh black: city_black_18 <- get_var(race_18, race_18$race_ethnicity, "NH Black") city_black_19 <- get_var(race_19, race_19$race_ethnicity, "NH Black") city_black_20 <- get_var(race_20, race_20$race_ethnicity, "NH Black") +city_black_21 <- get_var(race_21, race_21$race_ethnicity, "NH Black") # hispanic or latino: city_hispanic_18 <- get_var(race_18, race_18$race_ethnicity, "Hispanic or Latino") city_hispanic_19 <- get_var(race_19, race_19$race_ethnicity, "Hispanic or Latino") city_hispanic_20 <- get_var(race_20, race_20$race_ethnicity, "Hispanic or Latino") +city_hispanic_21 <- get_var(race_21, race_21$race_ethnicity, "Hispanic or Latino") # asian: city_asian_18 <- get_var(race_18, race_18$race_ethnicity, "NH Asian") city_asian_19 <- get_var(race_19, race_19$race_ethnicity, "NH Asian") city_asian_20 <- get_var(race_20, race_20$race_ethnicity, "NH Asian") +city_asian_21 <- get_var(race_21, race_21$race_ethnicity, "NH Asian") # sor: city_sor_18 <- get_var(race_18, race_18$race_ethnicity, "NH Other") city_sor_19 <- get_var(race_19, race_19$race_ethnicity, "NH Other") city_sor_20 <- get_var(race_20, race_20$race_ethnicity, "NH Other") +city_sor_21 <- get_var(race_21, race_21$race_ethnicity, "NH Other") ``` ```{r} @@ -213,6 +300,7 @@ city_sor_20 <- get_var(race_20, race_20$race_ethnicity, "NH Other") wp_18 <- read.csv("../data/input/agency_diversity_2018.csv") %>% janitor::clean_names() wp_19 <- read.csv("../data/input/agency_diversity_2019.csv") %>% janitor::clean_names() wp_20 <- read.csv("../data/input/agency_diversity_2020.csv") %>% janitor::clean_names() +wp_21 <- read.csv("../data/input/agency_diversity_2021.csv") %>% janitor::clean_names() ``` ```{r} @@ -262,6 +350,7 @@ wp$d5 <- abs(wp$x_female - city_female) / (wp$x_female + city_female) /2 + wp_18 <- run_calc(wp_18, city_female_18, city_male_18, city_white_18, city_black_18, city_hispanic_18, city_asian_18, city_sor_18) wp_19 <- run_calc(wp_19, city_female_19, city_male_19, city_white_19, city_black_19, city_hispanic_19, city_asian_19, city_sor_19) wp_20 <- run_calc(wp_20, city_female_20, city_male_20, city_white_20, city_black_20, city_hispanic_20, city_asian_20, city_sor_20) +wp_21 <- run_calc(wp_21, city_female_21, city_male_21, city_white_21, city_black_21, city_hispanic_21, city_asian_21, city_sor_21) ``` ```{r} @@ -299,7 +388,8 @@ run_calc_2 <- function(wp, city_female, city_male, city_white, city_black, city_ ```{r} # for github chart -write.csv(run_calc_2(wp_18, city_female_18, city_male_18, city_white_18, city_black_18, city_hispanic_18, city_asian_18, city_sor_18), '../data/output/agency_diversity_calculations_2018.csv', row.names = F) -write.csv(run_calc_2(wp_19, city_female_19, city_male_19, city_white_19, city_black_19, city_hispanic_19, city_asian_19, city_sor_19), '../data/output/agency_diversity_calculations_2019.csv', row.names = F) -write.csv(run_calc_2(wp_20, city_female_20, city_male_20, city_white_20, city_black_20, city_hispanic_20, city_asian_20, city_sor_20), '../data/output/agency_diversity_calculations_2020.csv', row.names = F) +# write.csv(run_calc_2(wp_18, city_female_18, city_male_18, city_white_18, city_black_18, city_hispanic_18, city_asian_18, city_sor_18), '../data/output/agency_diversity_calculations_2018.csv', row.names = F) +# write.csv(run_calc_2(wp_19, city_female_19, city_male_19, city_white_19, city_black_19, city_hispanic_19, city_asian_19, city_sor_19), '../data/output/agency_diversity_calculations_2019.csv', row.names = F) +# write.csv(run_calc_2(wp_20, city_female_20, city_male_20, city_white_20, city_black_20, city_hispanic_20, city_asian_20, city_sor_20), '../data/output/agency_diversity_calculations_2020.csv', row.names = F) +write.csv(run_calc_2(wp_21, city_female_21, city_male_21, city_white_21, city_black_21, city_hispanic_21, city_asian_21, city_sor_21), '../data/output/agency_diversity_calculations_2021.csv', row.names = F) ``` \ No newline at end of file diff --git a/code/02_agency_demo_improv.Rmd b/code/02_agency_demo_improv.Rmd index 2e885c6..9423a77 100644 --- a/code/02_agency_demo_improv.Rmd +++ b/code/02_agency_demo_improv.Rmd @@ -251,7 +251,7 @@ relative_plot <- cp %>% filter(agency_name =='DSNY',gender2!="Other") %>% ggplot(aes(x = data_year, y = diff_middle)) + facet_wrap(~gender2, nrow=1) + geom_hline(yintercept=0, size = 0.5, color="grey") + - geom_point(aes(color=data_year)) + geom_label_repel(data = ~ subset(., data_year %in% c(2019,2020)), aes(label = round(diff_middle, digits=0))) + # diff_middle rounded to 0 to make more sense + geom_point(aes(color=data_year)) + geom_label_repel(data = ~ subset(., data_year %in% c(2019,2020,2021)), aes(label = round(diff_middle, digits=0))) + # diff_middle rounded to 0 to make more sense scale_color_discrete(name = "Year") + theme_nycc(facet=TRUE) + ggtitle("Relative Difference") + xlab("Year") + ylab("Number") + easy_plot_title_size(14) diff --git a/data/input/agency_diversity_2021.csv b/data/input/agency_diversity_2021.csv new file mode 100644 index 0000000..ac9f3dc --- /dev/null +++ b/data/input/agency_diversity_2021.csv @@ -0,0 +1,73 @@ +Agency,# Employees,%Female,%Male,%White,%Black,%Hispanic,%Asian,%SOR,check gender,check eth/race +DCAS,2298,39,61,26,34,25,12,3,100,100 +DOITT,1673,38,62,35,26,15,20,4,100,100 +MAYORALTY,1243,59,41,42,20,16,18,4,100,100 +BOE,946,48,52,31,31,18,4,16,100,100 +NYCERS,484,61,39,30,35,11,22,2,100,100 +TRS,341,59,41,35,28,13,22,2,100,100 +OPA,146,61,39,27,33,20,18,2,100,100 +NYCPPF,147,55,45,34,28,17,19,2,100,100 +DORIS,62,56,44,39,21,15,23,3,100,101 +CLERK,68,71,29,22,9,47,22,0,100,100 +FDNYPF,46,70,30,39,26,7,28,0,100,100 +OCB,16,69,31,62,12,19,0,6,100,99 +DOF,2036,52,48,28,38,12,19,2,100,99 +COMPTROLLER,798,57,42,34,25,15,22,5,99,101 +TLC,594,40,60,22,34,25,15,3,100,99 +FISA,425,34,66,35,13,7,42,2,100,99 +DCA,388,60,40,28,23,27,19,3,100,100 +SBS,283,59,41,30,32,18,17,2,100,99 +BIC,82,51,49,43,17,20,17,4,100,101 +NYCTAX,51,51,49,53,14,10,24,0,100,101 +ACTUARY,43,44,56,49,7,7,35,2,100,100 +IBO,38,47,50,61,11,8,13,8,97,101 +MWFA,11,73,27,45,0,27,27,0,100,99 +COUNCIL,747,51,48,41,22,22,10,4,99,99 +BP-BK,120,64,35,30,41,17,3,9,99,100 +CFB,117,54,46,41,12,15,25,8,100,101 +BP-QNS,118,64,36,44,21,16,8,10,100,99 +BP-MAN,93,58,42,30,31,27,8,4,100,100 +BP-BX,91,59,41,23,20,46,1,10,100,100 +PA,73,53,45,23,40,18,4,15,98,100 +BP-SI,49,59,41,76,8,8,0,8,100,100 +PUBADMIN,46,57,43,35,26,30,4,4,100,99 +NYCHA,11937,39,61,16,51,24,5,4,100,100 +PARKS,6977,33,67,35,31,25,7,3,100,101 +HPD,2390,51,49,25,38,21,13,3,100,100 +LPC,75,72,28,69,9,8,7,7,100,100 +DCLA,79,62,38,39,19,19,15,8,100,100 +DOE,149419,78,22,44,21,23,8,5,100,101 +SCA,861,37,63,41,20,15,23,2,100,101 +NYCHH,41903,69,31,16,44,19,20,1,100,100 +HRA,12205,71,29,14,56,18,10,2,100,100 +DOHMH,6906,71,29,24,40,17,16,4,100,101 +ACS,7276,71,29,12,62,18,5,3,100,100 +DHS,2145,50,50,9,64,20,4,3,100,100 +DYCD,539,63,37,21,39,22,13,5,100,100 +DFTA,338,72,28,27,29,21,20,3,100,100 +DSNY,9359,9,91,51,21,22,5,1,100,100 +DEP,5976,46,48,48,21,14,15,2,94,100 +DOT,5759,26,74,40,31,16,11,2,100,100 +DOB,1674,36,64,34,31,15,16,4,100,100 +DDC,1226,38,62,31,23,15,29,2,100,100 +DCP,297,47,52,53,14,13,17,3,99,100 +LAW,1821,63,37,46,28,13,9,4,100,100 +DA-MAN,1553,57,43,55,14,19,8,4,100,100 +DA-BK,1174,56,44,39,29,20,8,5,100,101 +DA-BX,1049,61,39,35,26,31,6,3,100,101 +DA-QNS,794,59,41,50,15,18,10,6,100,99 +OATH,670,61,39,49,28,12,8,4,100,101 +DA-NARC,214,50,50,50,18,16,9,7,100,100 +CCRB,219,53,47,40,20,21,11,9,100,101 +DA-SI,213,59,41,67,10,15,3,5,100,100 +CCHR,128,57,41,27,24,23,18,9,98,101 +BOC,24,58,42,33,38,17,12,0,100,100 +COIB,24,54,46,50,4,17,21,8,100,100 +NYCCSC,15,67,33,40,40,13,7,0,100,100 +EEPC,13,69,31,15,46,8,15,15,100,99 +NYPD,54685,35,65,36,25,27,10,2,100,100 +FDNY,17564,12,88,62,13,19,4,1,100,99 +DOC,10372,44,56,12,59,22,5,2,100,100 +DOP,1084,69,31,11,63,20,3,2,100,99 +DOI,341,55,45,43,26,16,10,5,100,100 +NYCEM,206,50,49,53,18,11,10,8,99,100 \ No newline at end of file diff --git a/data/output/agency_diversity_calculations_2021.csv b/data/output/agency_diversity_calculations_2021.csv new file mode 100644 index 0000000..aa202bd --- /dev/null +++ b/data/output/agency_diversity_calculations_2021.csv @@ -0,0 +1,73 @@ +"agency","x_employees","x_female","x_male","x_white","x_black","x_hispanic","x_asian","x_sor","check_gender","check_eth_race","d1","d2","d4","d3","d5","d3_norm","d4_norm","d3_gender","d3_race","d4_gender","d4_race","d3_gender_norm","d3_race_norm","d3_norm_high","d3_gender_norm_high","d3_race_norm_high","d3_gender_race_norm_high" +"DCAS",2298,39,61,26,34,25,12,3,100,100,47.9368027752685,1.79170353094362,-1.5,21.8786294384801,0.42475226044697,22.6428236307202,0,14.3252436021833,16.5366811012498,0.102742506594418,0.322009753852552,23.5843110767982,20.7554857164242,FALSE,FALSE,FALSE,FALSE +"DOITT",1673,38,62,35,26,15,20,4,100,100,46.2683133687191,1.6261770466082,1.5,21.3088604553259,0.416834110604331,21.5251606484579,100,15.7394571645564,14.3644360164138,0.11316942458188,0.30366468602245,26.1315007075716,15.935287643634,FALSE,FALSE,FALSE,FALSE +"MAYORALTY",1243,59,41,42,20,16,18,4,100,100,42.0725568069446,1.32521055476509,0.5,19.6228538786967,0.346330466015075,18.2178778825241,66.6666666666667,13.9590276452786,13.791371996398,0.0993618978987054,0.24696856811637,22.9247066769605,14.6636622160298,FALSE,FALSE,FALSE,FALSE +"BOE",946,48,52,31,31,18,4,16,100,100,48.4696272381126,5.02810186909947,-0.5,21.8689170628514,0.840343845515184,22.6237717640323,33.3333333333333,1.59732154082544,21.8105042902976,0.011304083387486,0.829039762127698,0.659604399837658,32.4580659407012,FALSE,FALSE,FALSE,FALSE +"NYCERS",484,61,39,30,35,11,22,2,100,100,67.9354985273758,2.88719944594681,-0.5,28.8591559587266,0.748820619004576,36.3358752341791,33.3333333333333,16.7874547700248,23.474076020037,0.119935848457789,0.628884770546787,28.0190859385073,36.1495210631528,FALSE,FALSE,FALSE,FALSE +"TRS",341,59,41,35,28,13,22,2,100,100,51.217581332863,2.27770216447472,0.5,22.5506862365162,0.610356456101299,23.9611351347698,66.6666666666667,13.9590276452786,17.7109852051248,0.0993618978987054,0.510994558202594,22.9247066769605,23.3612590786851,FALSE,FALSE,FALSE,FALSE +"OPA",146,61,39,27,33,20,18,2,100,100,55.9354985273758,2.27069713668524,-0.5,23.7381188537703,0.576103638469119,26.2904115950096,33.3333333333333,16.7874547700248,16.7833146029053,0.119935848457789,0.45616779001133,28.0190859385073,21.30276389312,FALSE,FALSE,FALSE,FALSE +"NYCPPF",147,55,45,34,28,17,19,2,100,100,35.9354985273758,1.7578169309342,-0.5,15.866182556625,0.470770612029582,10.8487640884338,33.3333333333333,8.30217339578622,13.5207124748088,0.0588055096297518,0.41196510239983,12.735948153867,14.0630704534088,FALSE,FALSE,FALSE,FALSE +"DORIS",62,56,44,39,21,15,23,3,100,101,40.217581332863,1.652814705836,0.5,18.1521698256981,0.41748439497108,15.3329733453543,66.6666666666667,9.71638695815932,15.3327458030288,0.0688864819631795,0.348597913007901,15.2831377846404,18.0839609217498,FALSE,FALSE,FALSE,FALSE +"CLERK",68,71,29,22,9,47,22,0,100,100,98.2482899564004,4.021187068201,-0.5,41.2357669612547,1.26282543692859,60.6139254130602,33.3333333333333,30.9295903937557,27.2717603934436,0.227941318468119,1.03488411846047,53.4909822462413,44.5765586131731,FALSE,FALSE,FALSE,FALSE +"FDNYPF",46,70,30,39,26,7,28,0,100,100,89.217581332863,3.89992271211231,0.5,38.9448228677112,1.2607540924624,56.119992813199,66.6666666666667,29.5153768313827,25.4075138236483,0.216632617621866,1.04412147484053,50.9437926154679,40.4398072927707,FALSE,FALSE,FALSE,FALSE +"OCB",16,69,31,62,12,19,0,6,100,99,100.555953481825,3.90778560377003,-0.5,43.6673206544792,1.17918457903946,65.3836788265502,33.3333333333333,28.1011632690096,33.4239362743165,0.205458188321147,0.973726390718314,48.3966029846945,58.2281978924901,FALSE,FALSE,FALSE,FALSE +"DOF",2036,52,48,28,38,12,19,2,100,99,50.9354985273758,2.49356586909324,-0.5,24.9283425563144,0.639677905916052,28.6251630684588,33.3333333333333,4.05953270866694,24.5955779926437,0.0287088935128417,0.61096901240321,5.09437926154679,38.6381268308566,FALSE,FALSE,FALSE,FALSE +"COMPTROLLER",798,57,42,34,25,15,22,5,99,101,42.4683229902199,1.861135180535,0.5,19.0413874376226,0.455210947485837,17.0772690817103,66.6666666666667,11.8588074510539,14.8977555822507,0.0848372903121327,0.370373657173705,19.1419264495575,17.1187203793661,FALSE,FALSE,FALSE,FALSE +"TLC",594,40,60,22,34,25,15,3,100,99,47.4534061003879,1.69964867607212,-0.5,22.7063426664605,0.40787734218025,24.2664719201047,33.3333333333333,12.9110300398102,18.6784180432349,0.0923864840559099,0.315490858124341,21.0371214460248,25.5079864136278,FALSE,FALSE,FALSE,FALSE +"FISA",425,34,66,35,13,7,42,2,100,99,87.0576399171126,4.03338192905872,-0.5,40.6903136904514,0.953842923455373,59.543960309035,33.3333333333333,21.3963114140488,34.6106845656132,0.155726985521608,0.798115937933764,36.3202592306652,60.8615848277527,FALSE,FALSE,FALSE,FALSE +"DCA",388,60,40,28,23,27,19,3,100,100,35.9354985273758,1.24635680163466,-0.5,17.4213575222791,0.311110239482318,13.899406614516,33.3333333333333,15.3732412076517,8.19555688714502,0.109618875326163,0.201491364156155,25.4718963077339,2.24658396201309,FALSE,FALSE,FALSE,FALSE +"SBS",283,59,41,30,32,18,17,2,100,99,48.9354985273758,2.05998532612714,-0.5,21.0524254452724,0.533503580046247,21.0221358672452,33.3333333333333,13.9590276452786,15.7591295548676,0.0993618978987054,0.434141682147542,22.9247066769605,19.0301037641158,FALSE,FALSE,FALSE,FALSE +"BIC",82,51,49,43,17,20,17,4,100,101,25.0725568069446,0.967062338056126,0.5,12.0786650385714,0.244395555897194,3.41914217190807,66.6666666666667,2.64531914629385,11.7854332007041,0.0187052624254691,0.225690293471725,2.54718963077339,10.2124967445844,FALSE,FALSE,FALSE,FALSE +"NYCTAX",51,51,49,53,14,10,24,0,100,101,58.5397323441005,3.18070298869549,-0.5,27.9510277351152,1.06482577876729,34.5544843043688,33.3333333333333,2.64531914629385,27.8255680636251,0.0187052624254691,1.04612051634182,2.54718963077339,45.8054543225663,FALSE,FALSE,FALSE,FALSE +"ACTUARY",43,44,56,49,7,7,35,2,100,100,80.0576399171126,3.86348316224681,-0.5,35.4088745170702,1.03059479364791,49.1838508055639,33.3333333333333,7.25417579031782,34.6578321331382,0.051538049594134,0.979056744053772,10.8483629229312,60.9662049812092,FALSE,FALSE,FALSE,FALSE +"IBO",38,47,50,61,11,8,13,8,97,101,63.8149072683312,3.25483874298099,-1.5,34.3711581729535,0.786728698310507,47.1482588758536,0,2.30053957111781,34.2940815860683,0.0153911389807623,0.771337559329744,1.9261950496458,60.159044823176,FALSE,FALSE,FALSE,FALSE +"MWFA",11,73,27,45,0,27,27,0,100,99,94.5397323441005,4.0965251401757,-0.5,42.7025775994152,1.46491915800661,63.4912318315057,33.3333333333333,33.7580175185019,26.1516039059672,0.25099689402772,1.21392226397889,58.585361507788,42.090938468444,FALSE,FALSE,FALSE,FALSE +"COUNCIL",747,51,48,41,22,22,10,4,99,99,23.2338024705876,0.957331169440133,0.5,10.3356340985968,0.253839812562669,0,66.6666666666667,3.42618732693395,9.75123441523352,0.0238570986320919,0.229982713930577,3.95363868885604,5.69862253497248,FALSE,FALSE,FALSE,FALSE +"BP-BK",120,64,35,30,41,17,3,9,99,100,82.9517196651005,4.35267108804541,-0.5,34.5248236874064,1.01373495292925,47.4496902668774,33.3333333333333,21.7487002174862,26.8133826567334,0.158133078020561,0.855601874908693,36.9549590596007,43.5594213211962,FALSE,FALSE,FALSE,FALSE +"CFB",117,54,46,41,12,15,25,8,100,101,51.0725568069446,3.07607934806167,0.5,20.632448672021,0.673456372611097,20.1983063736238,66.6666666666667,6.88795983341313,19.4487518246511,0.0487529779088462,0.62470339470225,10.1887585230936,27.217352191232,FALSE,FALSE,FALSE,FALSE +"BP-QNS",118,64,36,44,21,16,8,10,100,99,64.2338024705876,3.46043066145646,0.5,27.2349001210805,0.727335411002344,33.1497231670537,66.6666666666667,21.0300954571441,17.3053422291684,0.151313623171623,0.576021787830721,35.6606548308275,22.4611398865205,FALSE,FALSE,FALSE,FALSE +"BP-MAN",93,58,42,30,31,27,8,4,100,100,39.9517196651005,1.54826070356814,-0.5,18.4221784399321,0.39444322203555,15.8626242072714,33.3333333333333,12.5448140829055,13.4908968604031,0.0891584183218061,0.305284803713744,20.3775170461871,13.9969097940519,FALSE,FALSE,FALSE,FALSE +"BP-BX",91,59,41,23,20,46,1,10,100,100,70.264511094125,4.04748933875787,-0.5,30.2130886177509,0.995096591505559,38.9917593875959,33.3333333333333,13.9590276452786,26.795079231501,0.0993618978987054,0.895734693606854,22.9247066769605,43.518806136636,FALSE,FALSE,FALSE,FALSE +"PA",73,53,45,23,40,18,4,15,98,100,71.9517196651005,5.5884942568988,-0.5,29.9241247500395,1.00077882697122,38.4249257625632,33.3333333333333,7.03164210314437,29.0862381787197,0.0495660336331337,0.951212793338091,10.4475496967345,48.6028733162256,FALSE,FALSE,FALSE,FALSE +"BP-SI",49,59,41,76,8,8,0,8,100,100,111.555953481825,5.05654388832817,-0.5,51.7051287255242,1.45720617325421,81.1507016114777,33.3333333333333,13.9590276452786,49.7851974357979,0.0993618978987054,1.35784427535551,22.9247066769605,94.5337326912692,TRUE,FALSE,TRUE,TRUE +"PUBADMIN",46,57,43,35,26,30,4,4,100,99,36.2244428883745,1.53412226703967,1.5,16.8172900041064,0.476937455325733,12.7144633764492,100,11.1306005205324,12.6067829018565,0.0790020456000698,0.397935409725663,17.8303274154138,12.0350665246792,FALSE,FALSE,FALSE,FALSE +"NYCHA",11937,39,61,16,51,24,5,4,100,100,82.4696272381125,3.31270379152846,-0.5,39.9662731766378,0.795115694699166,58.1236771699497,33.3333333333333,14.3252436021833,37.3107275105665,0.102742506594418,0.692373188104748,23.5843110767982,66.8529630062869,FALSE,FALSE,FALSE,FALSE +"PARKS",6977,33,67,35,31,25,7,3,100,101,54.2188855807556,1.9975226123781,-0.5,26.5085656571965,0.528950671470344,31.7249401988224,33.3333333333333,22.8105249764219,13.5049621806924,0.166615735691827,0.362334935778518,38.8674488614386,14.0281206506099,FALSE,FALSE,FALSE,FALSE +"HPD",2390,51,49,25,38,21,13,3,100,100,39.4188952022564,1.76903949996952,-1.5,21.2707049726547,0.39930304973581,21.4503145760797,0,2.64531914629385,21.1055721705896,0.0187052624254691,0.380597787310341,2.54718963077339,30.8938260358284,FALSE,FALSE,FALSE,FALSE +"LPC",75,72,28,69,9,8,7,7,100,100,121.555953481825,4.58068718165437,-0.5,52.9384001102906,1.19999445602147,83.5698957315338,33.3333333333333,32.3438039561288,41.908860064248,0.239393048476525,0.960601407544948,56.0381718770147,77.0561899940754,TRUE,FALSE,TRUE,TRUE +"DCLA",79,62,38,39,19,19,15,8,100,100,44.0725568069446,2.16429332856564,0.5,20.89334782532,0.449920554901332,20.710088050702,66.6666666666667,18.2016683323979,10.2582285638011,0.130319436097797,0.319601118803535,30.5662755692807,6.82363933666826,FALSE,FALSE,FALSE,FALSE +"DOE",149419,78,22,44,21,23,8,5,100,101,80.2338024705876,2.42219168658664,0.5,42.7054965922813,0.64412030023888,63.4969577491466,66.6666666666667,40.8290853303674,12.5197935397883,0.311642375299813,0.332477924939066,71.321309661655,11.8420376816996,FALSE,TRUE,FALSE,TRUE +"SCA",861,37,63,41,20,15,23,2,100,101,53.0576399171126,2.15566284414442,-0.5,23.5307247110577,0.573222983851175,25.8835857359314,33.3333333333333,17.1536707269295,16.1073457161528,0.123674153423825,0.449548830427349,28.678690338345,19.8027932185694,FALSE,FALSE,FALSE,FALSE +"NYCHH",41903,69,31,16,44,19,20,1,100,100,97.9354985273758,3.89708846603806,-0.5,42.3582128508423,1.02493257279484,62.8157234355495,33.3333333333333,28.1011632690096,31.6945234834937,0.205458188321147,0.819474384473695,48.3966029846945,54.3906418728789,FALSE,FALSE,FALSE,FALSE +"HRA",12205,71,29,14,56,18,10,2,100,100,115.418895202256,4.36467609910251,-1.5,52.5559564066651,1.0207672592403,82.8196913803329,0,30.9295903937557,42.4910460202355,0.227941318468119,0.792825940772179,53.4909822462413,78.3480569397743,TRUE,FALSE,TRUE,TRUE +"DOHMH",6906,71,29,24,40,17,16,4,100,101,85.4683229902199,2.68779120710962,0.5,39.4876996862639,0.632942664234035,57.1849039297464,66.6666666666667,30.9295903937557,24.5487039288648,0.227941318468119,0.405001345765917,53.4909822462413,38.5341135804788,FALSE,FALSE,FALSE,FALSE +"ACS",7276,71,29,12,62,18,5,3,100,100,127.418895202256,4.79182330922733,-1.5,58.1685592908929,1.12494977492583,93.8294140281225,0,30.9295903937557,49.2640003253148,0.227941318468119,0.897008456457707,53.4909822462413,93.3771996071195,TRUE,FALSE,TRUE,TRUE +"DHS",2145,50,50,9,64,20,4,3,100,100,89.4188952022564,4.13185668945958,-1.5,52.2630986077452,0.977137787985655,82.2452193915145,0,1.23110558392075,52.2485966809075,0.00870589080899861,0.968431897176656,0,100,TRUE,FALSE,TRUE,TRUE +"DYCD",539,63,37,21,39,22,13,5,100,100,67.9517196651005,2.5208840295307,-0.5,30.7869096576428,0.575608253241304,40.1173709138326,33.3333333333333,19.615881894771,23.7286953657013,0.140776392618365,0.434831860622939,33.1134652000541,36.7145197770797,FALSE,FALSE,FALSE,FALSE +"DFTA",338,72,28,27,29,21,20,3,100,100,73.9354985273758,2.34322850862019,-0.5,35.2511925895907,0.581949122176225,48.874540789529,33.3333333333333,32.3438039561288,14.018734773007,0.239393048476525,0.3425560736997,56.0381718770147,15.1681787760098,FALSE,FALSE,FALSE,FALSE +"DSNY",9359,9,91,51,21,22,5,1,100,100,115.218885580756,3.70991948295667,-0.5,60.2145986711285,1.18080674619021,97.8429397607467,33.3333333333333,56.7516504733761,20.1258058639353,0.486603147439598,0.694203598750617,100,28.7197308123714,TRUE,TRUE,FALSE,TRUE +"DEP",5976,46,48,48,21,14,15,2,94,100,35.476535119369,1.52216864713482,-0.5,19.4167215605485,0.438066640714579,17.8135272276906,33.3333333333333,4.24659022414135,18.9466500370935,0.0309650900130787,0.4071015507015,5.43129511107034,26.1031915076035,FALSE,FALSE,FALSE,FALSE +"DOT",5759,26,74,40,31,16,11,2,100,100,79.2188855807556,2.75290526784635,-0.5,36.8423349601782,0.74220867048273,51.9957372387813,33.3333333333333,32.7100199130335,16.9532369359636,0.246544611301199,0.495664059181531,56.6977762768523,21.6798204729917,FALSE,FALSE,FALSE,FALSE +"DOB",1674,36,64,34,31,15,16,4,100,100,50.986230563232,1.67465491285682,0.5,24.6605778092977,0.423405732211702,28.0999137927985,66.6666666666667,18.5678842893026,16.2289177367899,0.134263776824344,0.289141955387357,31.2258799691184,20.0725607616846,FALSE,FALSE,FALSE,FALSE +"DDC",1226,38,62,31,23,15,29,2,100,100,56.4534061003879,2.5599588267434,-0.5,24.8493347338858,0.628811365517415,28.4701807492235,33.3333333333333,15.7394571645564,19.2291165912997,0.11316942458188,0.515641940935535,26.1315007075716,26.7299830007536,FALSE,FALSE,FALSE,FALSE +"DCP",297,47,52,53,14,13,17,3,99,100,45.0576399171126,1.78195448351008,-0.5,24.3521415756557,0.47851834363834,27.4948830331007,33.3333333333333,2.41047503436376,24.2325485541552,0.0165658855027544,0.461952458135585,2.12420366693303,37.8325668081945,FALSE,FALSE,FALSE,FALSE +"LAW",1821,63,37,46,28,13,9,4,100,100,67.2338024705876,2.26205494683077,0.5,28.476561168885,0.607772775431618,35.5853745111576,66.6666666666667,19.615881894771,20.6429579638104,0.140776392618365,0.466996382813253,33.1134652000541,29.8672880436243,FALSE,FALSE,FALSE,FALSE +"DA-MAN",1553,57,43,55,14,19,8,4,100,100,57.5559534818252,2.04635147422488,-0.5,26.410188943505,0.53712015254453,31.5319637215824,33.3333333333333,11.1306005205324,23.9501108991995,0.0790020456000698,0.45811810694446,17.8303274154138,37.205839442298,FALSE,FALSE,FALSE,FALSE +"DA-BK",1174,56,44,39,29,20,8,5,100,101,42.2338024705876,1.90429848556576,0.5,17.0350774118851,0.485652621382519,13.1416767398893,66.6666666666667,9.71638695815932,13.9923438675666,0.0688864819631795,0.41676613941934,15.2831377846404,15.1096175241368,FALSE,FALSE,FALSE,FALSE +"DA-BX",1049,61,39,35,26,31,6,3,100,101,43.6916184255305,1.72065959863652,0.5,20.2296968685977,0.487441703171515,19.4082655061238,66.6666666666667,16.7874547700248,11.2881352640603,0.119935848457789,0.367505854713726,28.0190859385073,9.10899577568072,FALSE,FALSE,FALSE,FALSE +"DA-QNS",794,59,41,50,15,18,10,6,100,99,56.5559534818252,2.36829156642058,-0.5,23.9757776725818,0.577746928173802,26.7566048628907,33.3333333333333,13.9590276452786,19.4931644994706,0.0993618978987054,0.478385030275097,22.9247066769605,27.3159036351123,FALSE,FALSE,FALSE,FALSE +"OATH",670,61,39,49,28,12,8,4,100,101,68.2338024705876,2.37420957037141,0.5,28.780016605708,0.646929711116098,36.1806349035815,66.6666666666667,16.7874547700248,23.3767131600916,0.119935848457789,0.526993862658308,28.0190859385073,35.9334734941439,FALSE,FALSE,FALSE,FALSE +"DA-NARC",214,50,50,50,18,16,9,7,100,100,39.5559534818252,2.26911573879766,-0.5,20.3854744960872,0.53075239776291,19.7138400334451,33.3333333333333,1.23110558392075,20.3482664979565,0.00870589080899861,0.522046506953911,0,29.2133695490251,FALSE,FALSE,FALSE,FALSE +"CCRB",219,53,47,40,20,21,11,9,100,101,28.5559534818252,2.21376126423384,-0.5,11.8152771994186,0.420671885002488,2.90247867055428,33.3333333333333,5.47374627104004,10.4708584681188,0.0387227905822676,0.38194909442022,7.64156889232018,7.29546374642956,FALSE,FALSE,FALSE,FALSE +"DA-SI",213,59,41,67,10,15,3,5,100,100,87.5559534818252,3.42916704706565,-0.5,40.584764490662,0.975131954387611,59.3369142308879,33.3333333333333,13.9590276452786,38.1086427987255,0.0993618978987054,0.875770056488906,22.9247066769605,68.6235319725065,FALSE,FALSE,FALSE,FALSE +"CCHR",128,57,41,27,24,23,18,9,98,101,41.4683229902199,2.5386952878816,0.5,16.8122889883908,0.490823934184127,12.7046533476406,66.6666666666667,12.6242766277781,11.1031842574328,0.0907995669494473,0.400024367234679,20.5206398217845,8.69859066442959,FALSE,FALSE,FALSE,FALSE +"BOC",24,58,42,33,38,17,12,0,100,100,53.4188952022564,2.83576240382523,-1.5,24.4744062457443,0.917543847099435,27.7347182993871,0,12.5448140829055,21.014856666346,0.0891584183218061,0.828385428777629,20.3775170461871,30.6925289069823,FALSE,FALSE,FALSE,FALSE +"COIB",24,54,46,50,4,17,21,8,100,100,62.0725568069446,3.38942360025754,0.5,26.6594966021109,0.858932586006763,32.0210074383461,66.6666666666667,6.88795983341313,25.7543155298534,0.0487529779088462,0.810179608097916,10.1887585230936,41.2093580803682,FALSE,FALSE,FALSE,FALSE +"NYCCSC",15,67,33,40,40,13,7,0,100,100,86.7009780077435,3.90699687993149,-0.5,36.52560871832,1.23936754036338,51.3744447386589,33.3333333333333,25.2727361442634,26.3706067436124,0.183478611068985,1.0558889292944,43.3022237231477,42.5769043768592,FALSE,FALSE,FALSE,FALSE +"EEPC",13,69,31,15,46,8,15,15,100,99,115.46832299022,6.37897909755514,0.5,48.1691944332461,1.17333725863681,74.2145871808296,66.6666666666667,28.1011632690096,39.1228311255248,0.205458188321147,0.967879070315661,48.3966029846945,70.8740094404547,TRUE,FALSE,TRUE,TRUE +"NYPD",54685,35,65,36,25,27,10,2,100,100,41.2188855807556,1.63927295900133,-0.5,21.2339702664592,0.457227172970054,21.3782555091721,33.3333333333333,19.9820978516757,7.18312318723082,0.14494556362794,0.312281609342114,33.7730695998918,0,FALSE,FALSE,FALSE,FALSE +"FDNY",17564,12,88,62,13,19,4,1,100,99,130.541036591993,4.40254117427422,-1.5,61.314237863467,1.35109518681829,100,0,52.5090097862569,31.6581688675228,0.437379153571817,0.913716033246476,92.3584311076798,54.3099712105016,TRUE,TRUE,FALSE,TRUE +"DOC",10372,44,56,12,59,22,5,2,100,100,87.9368027752685,4.09289324331566,-1.5,46.732868355061,0.986974738881492,71.3970794969985,0,7.25417579031782,46.1664154802453,0.051538049594134,0.935436689287358,10.8483629229312,86.5036784723551,TRUE,FALSE,TRUE,TRUE +"DOP",1084,69,31,11,63,20,3,2,100,99,126.418895202256,5.11995130156007,-1.5,57.9691997618556,1.27710972409569,93.438348925679,0,28.1011632690096,50.7025910970868,0.205458188321147,1.07165153577454,48.3966029846945,96.5694234100578,TRUE,FALSE,TRUE,TRUE +"DOI",341,55,45,43,26,16,10,5,100,100,43.2338024705876,1.84435563152464,0.5,17.9687840222059,0.474174813940181,14.9732424191444,66.6666666666667,8.30217339578622,15.9358437537201,0.0588055096297518,0.415369304310429,12.735948153867,19.4222314511296,FALSE,FALSE,FALSE,FALSE +"NYCEM",206,50,49,53,18,11,10,8,99,100,48.5559534818252,2.76124415436408,-0.5,25.5587771765318,0.636952359050005,29.8618282057097,33.3333333333333,2.06316920591958,25.4753689588071,0.0137555795091358,0.62319677954087,1.49865896247149,40.5903774075355,FALSE,FALSE,FALSE,FALSE diff --git a/visuals/DOP_diversity_by-race.png b/visuals/DOP_diversity_by-race.png index ea91c81..51a1830 100644 Binary files a/visuals/DOP_diversity_by-race.png and b/visuals/DOP_diversity_by-race.png differ diff --git a/visuals/DSNY_diversity_by-gender.png b/visuals/DSNY_diversity_by-gender.png index a359ce8..f047875 100644 Binary files a/visuals/DSNY_diversity_by-gender.png and b/visuals/DSNY_diversity_by-gender.png differ