project_milestone_4_je

Project Milestone 3 Resubmission

Project Milestone 4 is below

Esmeralda Navarro & Juliet Munyambanza

  • Scenario 3

Q4. Cleaning age group was clarified and not needed due to focusing on race/ethnicity for our project –> will consider cleaning variables like these for real life work presentation

Q6. Data dictionary based on clean data set

Cal Enviro Screen Score data set

Varible Name Variable Type Description
county character ‘county’ is each county of California
median_score double ‘median_score’ is median CES 4.0 score by county

Cal Enviro Screen Measures data set

Variable Name Variable Type Description
county character ‘county’ is each county of California
mean_pb double ‘mean_pb’ is the mean measure of pollution burden of each county
mean_cleanup_sites double ‘mean_cleanup_sites’ is the mean measure for cleanup sites of each county
mean_lead double ‘mean_lead’ is the mean measure for lead of each county
mean_pesticides double ‘mean_pesticides’ is the mean measure for pesticides of each county

Asthma Data Set

Variable Name Variable Type Description
county character ‘county’ is each county of California
year double ‘year’ is the most recent year in the data set (2020)
white double ‘white’ is the number of asthma emergency department visits for people who identified as White in the county
black double ‘black’ is the number of asthma emergency department visits for people who identified as Black in the county
hispanic double ‘hispanic’ is the number of asthma emergency department visits for people who identified as Hispanic in the county
asian/pi double ‘asian/pi’ is the number of asthma emergency department visits for people who identified as Asian or Pacific Islander in the county
ai/an double ‘ai/an’ is the number of asthma emergency department visits for people who identified as American Indian or Alaska Native in the county
nhpi double ‘nhpi’ is the number of asthma emergency department visits for people who identified as Native Hawaiian and other Pacific Islander in the county
multi_race double ‘multi_race’ is the number of asthma emergency department visits for people who identified as multi-race in the county

Q7. Descriptive statistics for 4 data elements

Summarized CalEnviroScreen score into a county level variable

county median_ces_4.0_score
alameda  20.63
alpine  13.62
amador  19.63
butte  21.44
calaveras  16.14
colusa  27.44
contra costa  17.69
del norte  19.71
el dorado  9.51
fresno  42.82
glenn  26.41
humboldt  17.45
imperial  42.61
inyo  15.17
kern  39.61
kings  40.69
lake  19.87
lassen  15.42
los angeles  38.19
madera  41.30
marin  8.34
mariposa  14.87
mendocino  16.59
merced  43.70
modoc  15.22
mono  14.59
monterey  20.34
napa  17.79
nevada  11.28
orange  21.31
placer  9.94
plumas  15.84
riverside  24.74
sacramento  23.29
san benito  26.50
san bernardino  33.29
san diego  17.27
san francisco  16.22
san joaquin  36.12
san luis obispo  13.04
san mateo  13.70
santa barbara  17.78
santa clara  14.89
santa cruz  12.48
shasta  17.13
sierra  18.28
siskiyou  17.88
solano  22.12
sonoma  12.91
stanislaus  37.09
sutter  28.83
tehama  26.41
trinity  12.73
tulare  42.65
tuolumne  19.08
ventura  19.51
yolo  19.24
yuba  28.91

Summarized Environmental measures of interest on county level

county mean_pb mean_cleanup_sites mean_lead mean_pesticides
alameda 37.32 13.46 52.47 0.95
alpine 33.24 0.00 36.51 0.00
amador 36.67 34.31 28.10 2.01
butte 34.39 13.23 42.37 735.61
calaveras 28.82 3.40 30.65 1.20
colusa 41.69 8.20 56.17 1185.99
contra costa 35.39 9.92 42.35 10.51
del norte 24.16 6.43 46.35 47.41
el dorado 25.44 1.79 27.19 5.50
fresno 49.03 5.18 48.28 586.36
glenn 40.94 3.00 54.37 1022.58
humboldt 26.84 4.30 49.69 7.82
imperial 45.27 9.08 42.16 484.79
inyo 26.48 12.17 37.71 0.45
kern 44.07 6.79 48.42 673.14
kings 45.68 4.18 50.19 351.70
lake 28.73 11.83 40.95 29.41
lassen 34.24 6.50 43.93 29.43
los angeles 51.93 11.57 61.94 5.43
madera 46.92 3.64 43.00 372.71
marin 30.70 7.25 46.21 1.25
mariposa 26.27 4.07 27.35 0.03
mendocino 30.65 6.07 47.74 66.49
merced 49.96 4.28 55.41 1882.00
modoc 30.93 1.25 54.46 21.05
mono 32.22 0.33 31.35 2.33
monterey 33.67 6.52 50.35 4222.55
napa 37.26 5.29 43.38 23.18
nevada 30.90 28.31 26.33 1.06
orange 45.75 8.83 43.68 63.44
placer 28.15 5.20 22.38 19.65
plumas 28.36 3.71 34.45 0.27
riverside 37.43 3.62 35.20 36.96
sacramento 34.85 6.33 42.18 14.64
san benito 36.63 11.16 39.19 403.11
san bernardino 43.68 7.57 45.11 5.27
san diego 37.50 4.36 39.88 51.68
san francisco 36.95 9.08 58.04 0.01
san joaquin 46.33 6.22 47.11 405.14
san luis obispo 34.92 6.23 36.11 850.09
san mateo 36.11 9.44 54.17 12.79
santa barbara 35.62 4.80 46.09 2126.62
santa clara 35.22 13.28 42.34 39.49
santa cruz 34.59 6.94 45.90 2253.52
shasta 27.74 4.57 34.05 13.15
sierra 35.27 0.00 22.20 0.07
siskiyou 30.86 6.13 53.61 177.40
solano 34.58 4.33 40.49 31.25
sonoma 32.00 3.33 38.49 20.77
stanislaus 49.63 4.95 47.46 1127.35
sutter 45.50 4.99 44.23 1490.81
tehama 35.46 6.51 45.65 642.51
trinity 24.81 2.00 36.42 0.16
tulare 51.39 10.90 52.82 514.64
tuolumne 32.88 8.37 32.21 0.23
ventura 39.60 3.13 39.77 3595.84
yolo 38.92 6.91 39.15 111.74
yuba 42.27 4.92 48.01 684.78

Summarized Asthma Data for 2020 by county based on race/ethnicity

county year white black hispanic asian/pi ai/an nhpi multi_race
alameda 2020 726 1681 915 539 NA 78 137
alpine 2020 0 0 0 0 0 0 0
amador 2020 87 NA NA 0 0 0 NA
butte 2020 292 53 69 13 NA NA NA
calaveras 2020 90 NA 12 NA 0 NA NA
colusa 2020 20 NA 21 0 0 0 0
contra costa 2020 767 1005 850 209 NA 50 51
del norte 2020 73 NA 15 NA NA 0 NA
el dorado 2020 262 14 49 NA NA 0 NA
fresno 2020 736 550 1983 122 NA NA 46
glenn 2020 23 0 27 0 NA 0 0
humboldt 2020 289 37 45 NA 24 NA 13
imperial 2020 40 NA 418 NA 0 0 0
inyo 2020 22 NA 12 0 NA 0 0
kern 2020 660 520 1201 57 11 NA NA
kings 2020 109 53 252 NA NA NA 0
lake 2020 171 25 53 NA NA NA NA
lassen 2020 53 NA NA 11 NA NA 0
los angeles 2020 3754 6439 12755 1253 54 126 279
madera 2020 130 22 316 NA 0 0 NA
marin 2020 146 33 76 NA 0 0 NA
mariposa 2020 23 NA NA NA NA 0 0
mendocino 2020 205 11 70 NA 20 0 NA
merced 2020 242 127 616 19 0 0 NA
modoc 2020 19 0 NA NA NA NA 0
mono 2020 18 0 17 NA 0 NA NA
monterey 2020 191 57 587 30 NA NA NA
napa 2020 147 22 127 16 NA NA NA
nevada 2020 138 NA 17 NA NA NA NA
orange 2020 1765 286 2073 452 NA 33 41
placer 2020 436 30 74 35 NA NA 11
plumas 2020 40 NA NA NA NA NA NA
riverside 2020 1738 1074 2631 148 19 28 57
sacramento 2020 1609 1843 1179 468 13 103 129
san benito 2020 59 NA 141 NA 0 0 0
san bernardino 2020 1762 1483 2906 132 12 25 90
san diego 2020 1706 901 2221 380 21 35 80
san francisco 2020 364 445 328 207 NA 34 29
san joaquin 2020 633 718 1044 226 NA 16 160
san luis obispo 2020 261 NA 116 NA 0 NA 11
san mateo 2020 307 70 406 204 NA 41 14
santa barbara 2020 254 53 323 17 NA NA NA
santa clara 2020 713 267 1219 486 NA 33 31
santa cruz 2020 241 21 174 NA NA 0 NA
shasta 2020 316 15 29 18 13 NA NA
sierra 2020 NA 0 0 0 0 0 0
siskiyou 2020 62 NA NA NA NA 0 0
solano 2020 507 583 382 173 NA 56 46
sonoma 2020 500 44 275 34 NA 12 NA
stanislaus 2020 661 162 812 60 NA 22 NA
sutter 2020 82 16 67 NA 0 0 NA
tehama 2020 96 NA 52 NA NA 0 NA
trinity 2020 21 0 NA NA 0 0 0
tulare 2020 279 63 752 14 NA NA NA
tuolumne 2020 107 NA 16 0 NA 0 0
ventura 2020 538 66 667 37 0 NA 14
yolo 2020 155 60 189 18 0 0 11
yuba 2020 109 24 49 0 NA 0 NA

Project Milestone 4

Esmeralda Navarro & Juliet Munyambanza

  • Scenario 3

Importing data… again

install.packages("tidyverse")
library(tidyverse)

CalEnviro Measures Summary Data

CalEnviro Scores Summary Data

Asthma Summary Data

Final datasets for creation of visualization –> Joining

  1. First adding column in Asthma data set to sum up the number of ED visits by county (accross all race/ethnicity) –> prepping for visualizations

  2. Adding a column to see what percentage of ED visits each county had of the overall total of ED visits per county accross race/ethnicity.

asthma_ed_sum$total_ed_visits <- rowSums(asthma_ed_sum[, c("white", "black", "hispanic", "asian/pi", "ai/an", "nhpi", "multi_race")], na.rm = TRUE)

total_ed_visits_number <- sum(asthma_ed_sum$total_ed_visits)
asthma_ed_sum <- asthma_ed_sum %>% 
  mutate(percent_of_visits = (total_ed_visits / total_ed_visits_number) * 100)
asthma_ed_sum$percent_of_visits <- 
  round(asthma_ed_sum$percent_of_visits, 2)

average_median_score <- mean(calenviro_demog_sum_scores$median_score)
calenviro_demog_sum_scores <- calenviro_demog_sum_scores %>%
  mutate(difference_avg_median = median_score - average_median_score)
calenviro_demog_sum_scores$difference_avg_median <- 
  round(calenviro_demog_sum_scores$difference_avg_median, 2)
full_data <- asthma_ed_sum %>%
  full_join(calenviro_demog_sum_scores, by = "county") %>%
  full_join(calenviro_measures_sum, by = "county")

Used full_join to keep as much as possible/keep everything from all the data sets and simply have them on one data frame.

str() –> long output so it is hidden with include=FALSE

Visualizations

The table is part of the first task “to compare county asthma ED rates with a county CES measure to assess if there appears to be a correlation.”

install.packages("DT")
library(DT)
library(formattable)

Table: County asthma emergency department (ED) rates and median county Cal Enviro Screen (CES) scores

Interpretation: If there is a(n) correlation/association exists, we might expect to see high asthma ED percentages for a county with a high CES score (difference with larger “+” values). The table shows this correlation/association for Los Angeles county but not necessarily for the rest of the counties in California.

full_data_name_change <- full_data %>%
  rename("County" = county,
         "Latest Data Year" = year, 
         "Total County ED Visits" = total_ed_visits, 
         "County ED Visits Percent of Total ED Visits" = percent_of_visits, 
         "County Median CES Score" = median_score, 
         "Difference From Average of County Median CES Scores" = difference_avg_median)

datatable(
  full_data_name_change[, c("County",
                 "Latest Data Year",
                 "Total County ED Visits", 
                 "County ED Visits Percent of Total ED Visits", 
                 "County Median CES Score",
                 "Difference From Average of County Median CES Scores")],
  options = list(
    colnames = c("County",
                 "Latest Data Year",
                 "Total County ED Visits", 
                 "County ED Visits Percent of Total ED Visits", 
                 "County Median CES Score",
                 "Difference From Average of County Median CES Scores")))

The scatterplot is part of the second task “to compare asthma ED rates with county-level summaries for specific environmental measures to determine if those specific measures may be worth further investigation.” We will focus on mean lead measures in this plot.

Scatterplot: County mean lead meaures & County total emergency department visits

Interpretation: We might expect to see higher ED rates for counties with a higher mean lead measure. In this graph, we do see asthma ED rates and mean lead measure be high for Los Angeles county but not necessarily for the rest of the counties in California.

library(ggplot2)
install.packages("ggrepel")
library(ggrepel)
ggplot(full_data, aes(x = mean_lead, y = total_ed_visits, label = county)) + 
  geom_point() +
  geom_label_repel(nudge_x = 0.1, nudge_y = 0.1, size = 1.5, max.overlaps = Inf) +
  labs(
    x = "Mean Lead Measure", 
    y = "Total ED Visits",
    title = "County Mean Lead Measures & County Total Emergency 
    Department (ED) Visits", 
    subtitle = "Asthma Data from 2020")