Structure of Joined Data
str(flu_ca_la_vax_join)
## tibble [222,061 × 14] (S3: tbl_df/tbl/data.frame)
## $ county : chr [1:222061] "Alameda" "Alameda" "Alameda" "Alameda" ...
## $ new_dx : num [1:222061] 121 75 76 89 54 68 66 195 339 160 ...
## $ new_severe : num [1:222061] 0 0 0 0 0 1 0 1 0 0 ...
## $ cumulative_severe : num [1:222061] 0 0 0 0 0 1 1 2 2 2 ...
## $ susceptible_count : num [1:222061] 46000 45925 45849 45760 45706 ...
## $ pop : num [1:222061] 46000 46000 46000 46000 46000 46000 46000 46000 46000 46000 ...
## $ dt_dx : Date[1:222061], format: "2022-10-02" "2022-10-10" ...
## $ yr_dt_dx : num [1:222061] 2022 2022 2022 2022 2022 ...
## $ mo_dt_dx : num [1:222061] 10 10 10 10 10 11 11 11 11 11 ...
## $ day_dt_dx : num [1:222061] 2 10 16 24 27 10 15 19 29 29 ...
## $ tot_part_vax : num [1:222061] NA NA NA NA NA NA NA NA NA NA ...
## $ cumulative_unvax : num [1:222061] NA NA NA NA NA NA NA NA NA NA ...
## $ cumulative_fulvax : num [1:222061] NA NA NA NA NA NA NA NA NA NA ...
## $ cumulative_up2date: num [1:222061] NA NA NA NA NA NA NA NA NA NA ...
Tables: Newly diagnosed, County, Average number newly diagnosed, County with highest number of newly diagnosed Flu cases
avg_inc_rate <- mean(!is.na(flu_ca_la_vax_join$incidence_at_risk))
table_join_df<- flu_ca_la_vax_join %>%
select(county, incidence_at_risk, yr_dt_dx) %>%
filter(county==c("Los Angeles", "Riverside", "Orange", "Alameda", "Yolo") & incidence_at_risk>= avg_inc_rate) %>%
distinct(county, .keep_all = TRUE)
datatable(table_join_df)
ave_num_disease <- mean(!is.na(flu_ca_la_vax_join$new_dx))
# Orange county recorded the highest number of newly diagnosed cases
high_new_dx_county<- flu_ca_la_vax_join %>%
group_by(yr_dt_dx == 2022:2023) %>%
filter(county =="Orange", new_dx >= 10000)%>%
select(county,new_dx, incidence_at_risk)
datatable(high_new_dx_county)
#Most populated county with highest number of fully vaccinated individuals.
county_yr <- flu_ca_la_vax_join %>%
group_by(cumulative_fulvax) %>%
filter(incidence_at_risk >= 5100 & new_severe == 4) %>%
select(county, new_dx, incidence_at_risk, yr_dt_dx) %>%
drop_na()
datatable(county_yr)
New severe cases over time in 5 populated counties
library(ggplot2)
library(ggthemes)
ggplot(flu_ca_la_vax_join , aes(x = yr_dt_dx, y = new_severe, fill = county)) +
geom_bar(stat = "identity", position = "dodge") +
theme(panel.background = element_rect(fill = "white")) +
xlim(2021,2024) +
scale_fill_manual(values = c("Riverside" = "cyan3", "San Diego" = "orange",
"San Bernardino" = "blue", "Los Angeles" = "black", "Orange" = "green"),
name = "County") + labs(
title = "Number of New Severe Cases by Years and Counties;
highlighting 5 most populated counties in California",
caption =
"This represents the number of newly diagnosed
Flu cases that were severe in the 5 most populated counties",
x = "Year Diagnosis",
y = "# of New Severe Cases",
fill = "County")
Number of newly diagnosed per population over time
ggplot(flu_ca_la_vax_join , aes(x = yr_dt_dx, y = incidence_tot_pop, fill = county)) +
geom_bar(stat = "identity", position = "dodge") +
theme(panel.background = element_rect(fill = "white")) +
xlim(2021,2024) +
scale_fill_manual(values = c("Riverside" = "cyan3", "San Diego" = "orange",
"San Bernardino" = "blue", "Alameda" = "red", "Orange" = "green"),
name = "County") + labs(
title = "Total number of persons with up to date vaccination status by counties;
highlighting 5 counties in California",
x = "Year Diagnosis",
y = "Flu Rate per 100,000 population",
fill = "County"
)
Modeling and assessing relationship between newly diagnosed flu cases to vaccination status: up to date vaccination to number of newly diagnosed Flu cases
filter_df <- flu_ca_la_vax_join %>%
group_by(cumulative_up2date) %>%
mutate(count = n()) %>% filter(yr_dt_dx!=2023) %>% drop_na()
correlation_test <- cor.test(filter_df$cumulative_up2date,filter_df$new_dx)
scatter_model <- ggplot(filter_df, aes(x = cumulative_up2date, y = new_dx)) +
geom_point() +
geom_smooth(method = "lm", lwd = 1, col = "red") +
annotate("text", x = 22, y = 10 ,
label = paste("Correlation:",round(correlation_test$estimate, digits=3))) +
ggtitle("Newly diagnosed Flu cases compared
to up to date vaccination status from 2020 to 2024") + ylim(0,NA) +
xlab("Vaccination up to date") +
ylab("Newly Diagnosed") +
theme_bw() +
theme(plot.title = element_text(hjust = 0.5, size = 10)) +
scale_x_log10()
# Annotating the scatter plot with the p-value and CI to test if the correlation between newly diagnosed flu cases is significantly associated with up to date vaccination
p_value_text <- paste0("p-value: ", correlation_test$p.value)
confidence_interval <- paste0("confidence interval: ", round(correlation_test$conf.int, digits =3))
scatter_with_annotations <- scatter_model +
annotate("text", x = 22, y = 12, label = p_value_text) +labs(caption ="There is a positive weak correlation between having flu and vaccination status. This correlation is significant;
implying that those who are up to date with their vaccination status are less likely to have Flu")
print(scatter_with_annotations)
Histogram of number of newly diagnosed and incidence; that is number of newly diagnosed per susceptible count per 100,000 population
filtered_df<- flu_ca_la_vax_join %>%
group_by(cumulative_severe) %>%
mutate(count = n()) %>% filter(yr_dt_dx!=2023) %>% drop_na()
gg_hist2 <- ggplot(data = flu_ca_la_vax_join, aes(x = incidence_tot_pop)) +
geom_histogram(fill = "blue", color = "black", bins = 20) +
scale_y_continuous(limits=c(0,1000)) +
scale_x_continuous(limits = c(5000, 50000)) +
ggtitle("Incidence rate of flu in LA and CA") +
ylim(0, NA) +
xlab("Incidence") +
ylab("Frequency") +
theme_classic()
print(gg_hist2)
library(ggplot2)
gg_hist <- ggplot(data = flu_ca_la_vax_join, aes(x = new_dx)) +
geom_histogram(fill = "cyan3", color = "black", bins = 20) +
scale_y_continuous(limits=c(0,2000)) +
scale_x_continuous(limits = c(5000, 50000)) +
ggtitle("Newly Diagnosed Flu cases in LA and CA") +
xlab("Newly Diagnosed") +
ylab("Frequency") +
theme_classic()
print(gg_hist)
Rpub link: http://rpubs.com/Frida31/mil_st_4