This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
#Recode Recode column names, values, or formats that are in discordant #(dates, etc)
#Create new variables needed for analysis (minimum 2)
#recode age_category or sex in df2_new we use unique function
#mising values
##Recode Male =1 and Female = 2
#summary statistics ussing the describe function from the psych package
library(psych)
##
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
describe(df1)
## Warning in FUN(newX[, i], ...): no non-missing arguments to min; returning Inf
## Warning in FUN(newX[, i], ...): no non-missing arguments to max; returning -Inf
## vars n mean sd median trimmed mad
## county* 1 64888 30.25 16.07 32.00 30.46 20.76
## new_infections 2 64888 198.29 619.91 19.00 62.40 25.20
## new_recovered 3 64888 198.79 616.99 20.00 63.43 26.69
## count_susceptible 4 64888 11208.68 26578.38 1595.00 4882.82 2200.18
## current_infected 5 64888 221.23 676.03 22.00 71.01 29.65
## cumulative_infected 6 64888 2597.18 8260.12 202.50 761.49 279.47
## cumulative_recovered 7 64888 2375.95 7814.23 169.00 659.90 235.73
## new_unrecovered 8 64888 22.95 84.12 2.00 5.98 2.97
## cumulative_unrecovered 9 64888 272.17 1059.61 15.00 61.10 22.24
## new_severe 10 64888 4.39 18.66 0.00 0.88 0.00
## cumulative_severe 11 64888 47.96 220.64 2.00 8.20 2.97
## age_category* 12 64888 2.46 1.10 2.00 2.45 1.48
## sex* 13 64888 1.50 0.50 2.00 1.50 0.00
## race_ethnicity 14 64888 3.93 2.19 4.00 3.92 2.97
## dt_diagnosis 15 64888 NaN NA NA NaN NA
## population 16 64888 13775.47 31893.56 1986.00 6107.31 2725.02
## prevalence 17 64888 20.46 15.84 19.05 19.98 23.69
## incidence 18 64888 1.76 1.52 1.62 1.60 1.67
## min max range skew kurtosis se
## county* 1.00 57 56.00 -0.12 -1.12 0.06
## new_infections 1.00 12672 12671.00 7.33 75.93 2.43
## new_recovered 1.00 12584 12583.00 7.29 75.09 2.42
## count_susceptible 0.00 309574 309574.00 4.96 32.78 104.34
## current_infected 1.00 13202 13201.00 7.01 68.70 2.65
## cumulative_infected 2.00 134143 134141.00 7.05 67.87 32.43
## cumulative_recovered 1.00 133938 133937.00 7.33 73.79 30.68
## new_unrecovered 0.00 2417 2417.00 10.02 155.96 0.33
## cumulative_unrecovered 0.00 27779 27779.00 10.34 164.14 4.16
## new_severe 0.00 562 562.00 11.63 203.86 0.07
## cumulative_severe 0.00 6607 6607.00 12.57 235.92 0.87
## age_category* 1.00 4 3.00 0.06 -1.32 0.00
## sex* 1.00 2 1.00 0.00 -2.00 0.00
## race_ethnicity 1.00 7 6.00 0.06 -1.43 0.01
## dt_diagnosis Inf -Inf -Inf NA NA NA
## population 2.00 310091 310089.00 4.67 28.03 125.20
## prevalence 0.11 100 99.89 0.19 -1.42 0.06
## incidence 0.01 50 49.99 2.64 34.36 0.01
describe(df2_new)
## vars n mean sd median trimmed mad
## date_diagnosis* 1 1826 120.91 70.46 120 120.89 93.40
## age_category* 2 1826 2.53 1.12 3 2.54 1.48
## sex* 3 1826 1.50 0.50 2 1.50 0.00
## race_eth* 4 1826 4.01 1.99 4 4.01 2.97
## dx_new 5 1826 2416.36 5153.25 365 1197.99 536.70
## recovered_new 6 1826 2416.21 5130.09 370 1205.89 541.15
## infected_current 7 1826 2697.14 5532.47 432 1374.27 628.62
## infected_cumulative 8 1826 36619.03 74572.02 4268 18998.92 6257.31
## recovered_cumulative 9 1826 33921.89 71592.83 3434 16842.56 5060.11
## susceptible 10 1826 148767.94 215926.58 73322 102683.46 105547.78
## severe_new 11 1826 53.74 129.96 4 19.44 5.93
## severe_cumulative 12 1826 749.03 1850.87 35 250.86 51.89
## min max range skew kurtosis se
## date_diagnosis* 1 243 242 0.00 -1.24 1.65
## age_category* 1 4 3 -0.04 -1.36 0.03
## sex* 1 2 1 0.00 -2.00 0.01
## race_eth* 1 7 6 0.01 -1.24 0.05
## dx_new 0 51350 51350 4.30 24.56 120.60
## recovered_new 0 50717 50717 4.28 24.34 120.05
## infected_current 1 53361 53360 4.01 21.57 129.47
## infected_cumulative 2 543098 543096 3.82 18.46 1745.12
## recovered_cumulative 0 543097 543097 3.97 20.05 1675.40
## susceptible 884 1255986 1255102 2.68 8.75 5053.07
## severe_new 0 1107 1107 3.80 16.84 3.04
## severe_cumulative 0 12534 12534 3.63 14.60 43.31
describe(df3_new_missing)
## Warning in FUN(newX[, i], ...): no non-missing arguments to min; returning Inf
## Warning in FUN(newX[, i], ...): no non-missing arguments to min; returning Inf
## Warning in FUN(newX[, i], ...): no non-missing arguments to min; returning Inf
## Warning in FUN(newX[, i], ...): no non-missing arguments to max; returning -Inf
## Warning in FUN(newX[, i], ...): no non-missing arguments to max; returning -Inf
## Warning in FUN(newX[, i], ...): no non-missing arguments to max; returning -Inf
## vars n mean sd median trimmed
## county_name* 1 10640 30.46 16.87 31.0 30.51
## county_type* 2 10640 1.00 0.00 1.0 1.00
## demographic_category* 3 10640 2.07 0.92 2.0 2.09
## demographic_value* 4 10640 7.77 4.27 8.0 7.70
## population 5 10640 292596.72 1484704.42 22904.0 65373.24
## dt_admin 6 10640 NaN NA NA NaN
## total_partial_vaccinated 7 10640 18170.65 112015.82 705.5 3035.30
## cumulative_fully_vaccinated 8 10640 153621.31 906089.33 4787.0 25461.68
## cumulative_at_least_o_ne_dose 9 10640 171800.71 1007203.19 5883.0 29288.55
## cumulative_unvaccinated 10 10640 120952.37 741937.38 9101.0 24223.67
## suppress_data 11 10640 NaN NA NA NaN
## cumulative_up_to_date_vax 12 10640 17602.03 162027.16 1.5 725.42
## quarter 13 10640 NaN NA NA NaN
## mad min max range skew kurtosis
## county_name* 20.76 1 59 58 -0.03 -1.18
## county_type* 0.00 1 1 0 NaN NaN
## demographic_category* 1.48 1 3 2 -0.14 -1.82
## demographic_value* 5.93 1 15 14 0.07 -1.16
## population 32485.25 75 20036369 20036294 10.31 118.00
## dt_admin NA Inf -Inf -Inf NA NA
## total_partial_vaccinated 1043.01 0 2712324 2712324 12.93 199.25
## cumulative_fully_vaccinated 7097.21 0 15143943 15143943 11.81 157.90
## cumulative_at_least_o_ne_dose 8716.21 0 16868991 16868991 11.77 157.11
## cumulative_unvaccinated 12849.69 0 20035473 20035473 16.55 347.13
## suppress_data NA Inf -Inf -Inf NA NA
## cumulative_up_to_date_vax 2.22 0 4590329 4590329 18.51 392.43
## quarter NA Inf -Inf -Inf NA NA
## se
## county_name* 0.16
## county_type* 0.00
## demographic_category* 0.01
## demographic_value* 0.04
## population 14393.59
## dt_admin NA
## total_partial_vaccinated 1085.95
## cumulative_fully_vaccinated 8784.16
## cumulative_at_least_o_ne_dose 9764.42
## cumulative_unvaccinated 7192.77
## suppress_data NA
## cumulative_up_to_date_vax 1570.79
## quarter NA
#Summary statistics for individual columns in the dataset
new_infection <- summary(df1$new_infections)
new_infection
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.0 5.0 19.0 198.3 104.0 12672.0
new_recover <- summary(df1$new_recovered)
new_recover
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.0 5.0 20.0 198.8 106.0 12584.0
count_susceptible <- summary(df1$count_susceptible)
count_susceptible
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0 348 1595 11209 9496 309574
population <- summary(df1$population)
population
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 2 449 1986 13775 12196 310091
prevalence <- summary(df1$prevalence)
prevalence
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.1114 3.5760 19.0476 20.4635 36.4312 100.0000
incidence <- summary(df1$incidence)
incidence
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.00788 0.43814 1.61766 1.75632 2.65652 50.00000
# hormonising code of df1 to match df2_1
#df1$sex <- ifelse(df1$sex == "MALE", 1, 2)
#q5, datasets from CA and LA are bound together to one dataset called join_df using left_join function
joint_df <- left_join(df1, df2_1, by = join_by(new_infections, new_recovered, count_susceptible, current_infected, cumulative_infected, cumulative_recovered, new_severe, cumulative_severe, age_category, sex, dt_diagnosis))
#data aggregation to have descriptive statistics by county
names(joint_df$race_eth)
## NULL
summary_joint_df <- joint_df %>% select(-race_eth) %>% drop_na(county) %>%
group_by(county) %>%
summarise(
mean_new_infections= mean(new_infection, na.rm = T),
mean_new_recovered= mean(new_recovered, na.rm = T),
median_count_susceptible= median(count_susceptible, na.rm = T),
min_current_infected= min(current_infected, na.rm = T),
max_cumulative_infected= max(cumulative_infected, na.rm = T),
max_cumulative_recovered= max(cumulative_recovered, na.rm= T),
sd_prevalence= sd(prevalence, na.rm= T)
)
df4 <- summary_joint_df
df5 <- describe(summary_joint_df)
#q6, data dictionary for cleaned joint df, df4
library(dataMeta)
colnames(summary_joint_df)
## [1] "county" "mean_new_infections"
## [3] "mean_new_recovered" "median_count_susceptible"
## [5] "min_current_infected" "max_cumulative_infected"
## [7] "max_cumulative_recovered" "sd_prevalence"
str(summary_joint_df)
## tibble [57 × 8] (S3: tbl_df/tbl/data.frame)
## $ county : chr [1:57] "Alameda County" "Alpine County" "Amador County" "Butte County" ...
## $ mean_new_infections : num [1:57] 2167 2167 2167 2167 2167 ...
## $ mean_new_recovered : num [1:57] 450 2.48 20.94 76.12 23.65 ...
## $ median_count_susceptible: num [1:57] 16686.5 61.5 315 1057 350.5 ...
## $ min_current_infected : num [1:57] 1 1 1 1 1 1 1 1 1 1 ...
## $ max_cumulative_infected : num [1:57] 48249 60 2443 15767 2981 ...
## $ max_cumulative_recovered: num [1:57] 48165 59 2431 15729 2969 ...
## $ sd_prevalence : num [1:57] 16.2 13.5 14.8 15.8 14.8 ...
var_desc <- c("county","average new infections","average of new recovered cases","median of number of susceptible persons","minimum number of persons currently infected","maximum cumulated total of infected cases","maximum total cases recovered","standard deviation of prevalence")
var_type <- c(1,0,0,0,0,0,0,0)
#build linker
linker <- build_linker(summary_joint_df, variable_description = var_desc, variable_type = var_type)
## data dictionary built
dict <- build_dict(my.data = summary_joint_df, linker = linker, option_description = NULL,
prompt_varopts = FALSE)
# Load the knitr package
library(knitr)
#Data dictionary1
# Create a data frame with the variable details
variable_details <- data.frame(
Variable_Name = c("dt_diagnosis", "new_infections", "new_recovered", "count_susceptible", "current_infected", "cumulative_infected", "cumulative_recovered", "new_severe", "cumulative_severe"),
Data_Type = c("Date", "Integer", "Integer", "Integer", "Integer", "Integer", "Integer", "Integer", "Integer"),
Description = c("Date of diagnosis", "Number of new infections", "Number of new recoveries", "Count of susceptible individuals", "Number of currently infected individuals", "Cumulative count of infected individuals", "Cumulative count of recovered individuals", "Number of new severe cases", "Cumulative count of severe cases"),
Range_Transformations_Issues = c("Date format, No missing values", "Non-negative integers, No missing values", "Non-negative integers, No missing values", "Non-negative integers, No missing values", "Non-negative integers, No missing values", "Non-negative integers, No missing values", "Non-negative integers, No missing values", "Non-negative integers, No missing values", "Non-negative integers, No missing values")
)
# Create the table using kable
knitr::kable(variable_details, align = "c" )
| Variable_Name | Data_Type | Description | Range_Transformations_Issues |
|---|---|---|---|
| dt_diagnosis | Date | Date of diagnosis | Date format, No missing values |
| new_infections | Integer | Number of new infections | Non-negative integers, No missing values |
| new_recovered | Integer | Number of new recoveries | Non-negative integers, No missing values |
| count_susceptible | Integer | Count of susceptible individuals | Non-negative integers, No missing values |
| current_infected | Integer | Number of currently infected individuals | Non-negative integers, No missing values |
| cumulative_infected | Integer | Cumulative count of infected individuals | Non-negative integers, No missing values |
| cumulative_recovered | Integer | Cumulative count of recovered individuals | Non-negative integers, No missing values |
| new_severe | Integer | Number of new severe cases | Non-negative integers, No missing values |
| cumulative_severe | Integer | Cumulative count of severe cases | Non-negative integers, No missing values |
#The data dictionary provides a clear overview of the variables in the merged dataset, including their data types, specific range of values, any data transformations or cleaning steps applied, and the absence of missing values. This information ensures the dataset's integrity and suitability for analysis. Additionally, the variables are essential for tracking the progression of infections, recoveries, and severe cases, contributing to a comprehensive understanding of the dataset's context and significance
library(formattable)
# Assuming df4 is your data frame
formattable(head(df4, 10), list(
col.names = gsub("_", " ", names(df4)),
caption = "Portion of Summary Statistic of California sim flu"
))
| county | mean_new_infections | mean_new_recovered | median_count_susceptible | min_current_infected | max_cumulative_infected | max_cumulative_recovered | sd_prevalence |
|---|---|---|---|---|---|---|---|
| Alameda County | 2166.548 | 450.003086 | 16686.5 | 1 | 48249 | 48165 | 16.20953 |
| Alpine County | 2166.548 | 2.477941 | 61.5 | 1 | 60 | 59 | 13.45476 |
| Amador County | 2166.548 | 20.942257 | 315.0 | 1 | 2443 | 2431 | 14.81381 |
| Butte County | 2166.548 | 76.123351 | 1057.0 | 1 | 15767 | 15729 | 15.76287 |
| Calaveras County | 2166.548 | 23.649367 | 350.5 | 1 | 2981 | 2969 | 14.83959 |
| Colusa County | 2166.548 | 16.155405 | 705.5 | 1 | 1454 | 1452 | 15.54391 |
| Contra Costa County | 2166.548 | 317.304978 | 10082.0 | 1 | 39267 | 39208 | 16.11030 |
| Del Norte County | 2166.548 | 13.785627 | 242.0 | 1 | 1395 | 1390 | 15.06617 |
| El Dorado County | 2166.548 | 68.258361 | 795.0 | 1 | 11347 | 11326 | 15.52665 |
| Fresno County | 2166.548 | 292.701187 | 5527.5 | 1 | 57744 | 57643 | 16.14435 |
##Final datasets for creation of visualization #cleaning flu_ca_vax
# renaming joint data set of LA and CA from Milestone 3 and subsetting the joint data
df_Ca_and_la <- joint_df %>% select(-race_eth)# remove race_eth
df_vax <- df3_new_missing # assigning new name (df_vax) to vax_rates data
#using pivot wider to seperate demographic variables and clean new colnames in df_vax with janitor function
df_vax <- df_vax %>% pivot_wider(names_from = demographic_category,
values_from = demographic_value, values_fn = list)
df_vax <- janitor::clean_names(df_vax)
colnames(df_vax)
## [1] "county_name" "county_type"
## [3] "population" "dt_admin"
## [5] "total_partial_vaccinated" "cumulative_fully_vaccinated"
## [7] "cumulative_at_least_o_ne_dose" "cumulative_unvaccinated"
## [9] "suppress_data" "cumulative_up_to_date_vax"
## [11] "quarter" "age_group"
## [13] "gender" "race_ethnicity"
colnames(df_Ca_and_la)
## [1] "county" "new_infections" "new_recovered"
## [4] "count_susceptible" "current_infected" "cumulative_infected"
## [7] "cumulative_recovered" "new_unrecovered" "cumulative_unrecovered"
## [10] "new_severe" "cumulative_severe" "age_category"
## [13] "sex" "race_ethnicity" "dt_diagnosis"
## [16] "population" "prevalence" "incidence"
#rename new colnames in df_vax to match df_ca_and_la colnames
df_vax <- df_vax %>%
rename(county=county_name,
sex=gender,
age_category=age_group)
df_vax$sex <- ifelse(df_vax$sex == "male", "MALE", "FEMALE")
#str(df_vax)
#subset df_vax by using select function to work with variables of interest
sum(is.na(df_vax$race_ethnicity)) # to count NA in race_ethnicity
## [1] 0
#df_vax$age_category <- unlist(df_vax$age_category) # to convert age_category from list to character
subset_df_vax <- df_vax %>%
select(-county_type, -suppress_data, -race_ethnicity, -age_category)
#Joining all 3 datasets (already join LA and CA data(df_ca_and_la) with subsetted vax rates data(subset_df_vax))
final_joint_data <- full_join(df_Ca_and_la, subset_df_vax,
by = join_by(county, sex, population))
#Calculate any remaining data elements needed for analysis
#rearrange some columns in final_joint_data
final_joint_data_arrange <- final_joint_data[do.call(order, c(final_joint_data, list(decreasing=TRUE))),]
# calculate any remaining data elements
new_final_joint_data <- final_joint_data %>%
group_by(county) %>%
mutate(infection_rate_by_county= (new_infections/population)*100000) %>%
ungroup()
#Show code used to create joined datase
new_final_joint_data <- full_join(df_Ca_and_la, subset_df_vax,
by = join_by(county, sex, population)) %>%
group_by(county) %>%
mutate(infection_rate_by_county= (new_infections/population)*100000) %>%
ungroup()
str(new_final_joint_data)
## tibble [75,526 × 26] (S3: tbl_df/tbl/data.frame)
## $ county : chr [1:75526] "Alameda County" "Alameda County" "Alameda County" "Alameda County" ...
## $ new_infections : num [1:75526] 75 76 89 54 68 66 195 339 160 341 ...
## $ new_recovered : num [1:75526] 119 77 75 88 55 67 66 195 334 166 ...
## $ count_susceptible : num [1:75526] 45925 45849 45760 45706 45638 ...
## $ current_infected : num [1:75526] 77 76 90 56 69 68 197 341 167 342 ...
## $ cumulative_infected : num [1:75526] 196 272 361 415 483 ...
## $ cumulative_recovered : num [1:75526] 119 196 271 359 414 ...
## $ new_unrecovered : num [1:75526] 2 0 1 2 1 2 2 2 7 1 ...
## $ cumulative_unrecovered : num [1:75526] 2 2 3 5 6 8 10 12 19 20 ...
## $ new_severe : num [1:75526] 0 0 0 0 1 0 1 0 0 0 ...
## $ cumulative_severe : num [1:75526] 0 0 0 0 1 1 2 2 2 2 ...
## $ age_category : chr [1:75526] "0-17" "0-17" "0-17" "0-17" ...
## $ sex : chr [1:75526] "FEMALE" "FEMALE" "FEMALE" "FEMALE" ...
## $ race_ethnicity : num [1:75526] 1 1 1 1 1 1 1 1 1 1 ...
## $ dt_diagnosis : POSIXct[1:75526], format: "2022-10-10" "2022-10-16" ...
## $ population : num [1:75526] 46000 46000 46000 46000 46000 46000 46000 46000 46000 46000 ...
## $ prevalence : num [1:75526] 0.426 0.591 0.785 0.902 1.05 ...
## $ incidence : num [1:75526] 0.163 0.165 0.193 0.117 0.148 ...
## $ dt_admin : Date[1:75526], format: NA NA ...
## $ total_partial_vaccinated : num [1:75526] NA NA NA NA NA NA NA NA NA NA ...
## $ cumulative_fully_vaccinated : num [1:75526] NA NA NA NA NA NA NA NA NA NA ...
## $ cumulative_at_least_o_ne_dose: num [1:75526] NA NA NA NA NA NA NA NA NA NA ...
## $ cumulative_unvaccinated : num [1:75526] NA NA NA NA NA NA NA NA NA NA ...
## $ cumulative_up_to_date_vax : num [1:75526] NA NA NA NA NA NA NA NA NA NA ...
## $ quarter : Date[1:75526], format: NA NA ...
## $ infection_rate_by_county : num [1:75526] 163 165 193 117 148 ...
#One print quality table as requested in scenario #For each visual, include; Code used to generate visual,Legend (if necessary),1-2 sentence interpretation
#install gtsummary package to create beautiful tables
install.packages("gtsummary")
## Installing package into '/usr/local/lib/R/site-library'
## (as 'lib' is unspecified)
library(gtsummary)
#creating professional descriptive statistics for our joint data using summary function of gtsummary #package which will distinguish summary statistics for categorical data and #numerical
tbl_summary(new_final_joint_data)
| Characteristic | N = 75,5261 |
|---|---|
| county | |
| Â Â Â Â Alameda | 195 (0.3%) |
| Â Â Â Â Alameda County | 1,620 (2.1%) |
| Â Â Â Â Alpine | 74 (<0.1%) |
| Â Â Â Â Alpine County | 136 (0.2%) |
| Â Â Â Â Amador | 181 (0.2%) |
| Â Â Â Â Amador County | 762 (1.0%) |
| Â Â Â Â Butte | 195 (0.3%) |
| Â Â Â Â Butte County | 1,289 (1.7%) |
| Â Â Â Â Calaveras | 167 (0.2%) |
| Â Â Â Â Calaveras County | 790 (1.0%) |
| Â Â Â Â Colusa | 154 (0.2%) |
| Â Â Â Â Colusa County | 592 (0.8%) |
| Â Â Â Â Contra Costa | 195 (0.3%) |
| Â Â Â Â Contra Costa County | 1,587 (2.1%) |
| Â Â Â Â Del Norte | 168 (0.2%) |
| Â Â Â Â Del Norte County | 821 (1.1%) |
| Â Â Â Â El Dorado | 195 (0.3%) |
| Â Â Â Â El Dorado County | 1,196 (1.6%) |
| Â Â Â Â Fresno | 195 (0.3%) |
| Â Â Â Â Fresno County | 1,516 (2.0%) |
| Â Â Â Â Glenn | 156 (0.2%) |
| Â Â Â Â Glenn County | 706 (0.9%) |
| Â Â Â Â Humboldt | 194 (0.3%) |
| Â Â Â Â Humboldt County | 1,218 (1.6%) |
| Â Â Â Â Imperial | 195 (0.3%) |
| Â Â Â Â Imperial County | 1,099 (1.5%) |
| Â Â Â Â Inyo | 155 (0.2%) |
| Â Â Â Â Inyo County | 639 (0.8%) |
| Â Â Â Â Kern | 195 (0.3%) |
| Â Â Â Â Kern County | 1,491 (2.0%) |
| Â Â Â Â Kings | 168 (0.2%) |
| Â Â Â Â Kings County | 1,165 (1.5%) |
| Â Â Â Â Lake | 167 (0.2%) |
| Â Â Â Â Lake County | 1,008 (1.3%) |
| Â Â Â Â Lassen | 142 (0.2%) |
| Â Â Â Â Lassen County | 743 (1.0%) |
| Â Â Â Â Los Angeles | 195 (0.3%) |
| Â Â Â Â Madera | 181 (0.2%) |
| Â Â Â Â Madera County | 1,152 (1.5%) |
| Â Â Â Â Marin | 195 (0.3%) |
| Â Â Â Â Marin County | 1,258 (1.7%) |
| Â Â Â Â Mariposa | 167 (0.2%) |
| Â Â Â Â Mariposa County | 589 (0.8%) |
| Â Â Â Â Mendocino | 195 (0.3%) |
| Â Â Â Â Mendocino County | 1,046 (1.4%) |
| Â Â Â Â Merced | 182 (0.2%) |
| Â Â Â Â Merced County | 1,293 (1.7%) |
| Â Â Â Â Modoc | 129 (0.2%) |
| Â Â Â Â Modoc County | 428 (0.6%) |
| Â Â Â Â Mono | 153 (0.2%) |
| Â Â Â Â Mono County | 476 (0.6%) |
| Â Â Â Â Monterey | 194 (0.3%) |
| Â Â Â Â Monterey County | 1,440 (1.9%) |
| Â Â Â Â Napa | 194 (0.3%) |
| Â Â Â Â Napa County | 1,160 (1.5%) |
| Â Â Â Â Nevada | 194 (0.3%) |
| Â Â Â Â Nevada County | 931 (1.2%) |
| Â Â Â Â Orange | 195 (0.3%) |
| Â Â Â Â Orange County | 1,631 (2.2%) |
| Â Â Â Â Placer | 195 (0.3%) |
| Â Â Â Â Placer County | 1,403 (1.9%) |
| Â Â Â Â Plumas | 155 (0.2%) |
| Â Â Â Â Plumas County | 562 (0.7%) |
| Â Â Â Â Riverside | 195 (0.3%) |
| Â Â Â Â Riverside County | 1,622 (2.1%) |
| Â Â Â Â Sacramento | 195 (0.3%) |
| Â Â Â Â Sacramento County | 1,639 (2.2%) |
| Â Â Â Â San Benito | 194 (0.3%) |
| Â Â Â Â San Benito County | 855 (1.1%) |
| Â Â Â Â San Bernardino | 195 (0.3%) |
| Â Â Â Â San Bernardino County | 1,620 (2.1%) |
| Â Â Â Â San Diego | 195 (0.3%) |
| Â Â Â Â San Diego County | 1,659 (2.2%) |
| Â Â Â Â San Francisco | 195 (0.3%) |
| Â Â Â Â San Francisco County | 1,518 (2.0%) |
| Â Â Â Â San Joaquin | 195 (0.3%) |
| Â Â Â Â San Joaquin County | 1,558 (2.1%) |
| Â Â Â Â San Luis Obispo | 195 (0.3%) |
| Â Â Â Â San Luis Obispo County | 1,245 (1.6%) |
| Â Â Â Â San Mateo | 195 (0.3%) |
| Â Â Â Â San Mateo County | 1,548 (2.0%) |
| Â Â Â Â Santa Barbara | 195 (0.3%) |
| Â Â Â Â Santa Barbara County | 1,374 (1.8%) |
| Â Â Â Â Santa Clara | 195 (0.3%) |
| Â Â Â Â Santa Clara County | 1,589 (2.1%) |
| Â Â Â Â Santa Cruz | 195 (0.3%) |
| Â Â Â Â Santa Cruz County | 1,242 (1.6%) |
| Â Â Â Â Shasta | 182 (0.2%) |
| Â Â Â Â Shasta County | 1,213 (1.6%) |
| Â Â Â Â Sierra | 102 (0.1%) |
| Â Â Â Â Sierra County | 226 (0.3%) |
| Â Â Â Â Siskiyou | 169 (0.2%) |
| Â Â Â Â Siskiyou County | 901 (1.2%) |
| Â Â Â Â Solano | 195 (0.3%) |
| Â Â Â Â Solano County | 1,527 (2.0%) |
| Â Â Â Â Sonoma | 195 (0.3%) |
| Â Â Â Â Sonoma County | 1,463 (1.9%) |
| Â Â Â Â Stanislaus | 182 (0.2%) |
| Â Â Â Â Stanislaus County | 1,515 (2.0%) |
| Â Â Â Â Statewide | 195 (0.3%) |
| Â Â Â Â Sutter | 181 (0.2%) |
| Â Â Â Â Sutter County | 1,189 (1.6%) |
| Â Â Â Â Tehama | 182 (0.2%) |
| Â Â Â Â Tehama County | 885 (1.2%) |
| Â Â Â Â Trinity | 155 (0.2%) |
| Â Â Â Â Trinity County | 526 (0.7%) |
| Â Â Â Â Tulare | 193 (0.3%) |
| Â Â Â Â Tulare County | 1,370 (1.8%) |
| Â Â Â Â Tuolumne | 182 (0.2%) |
| Â Â Â Â Tuolumne County | 859 (1.1%) |
| Â Â Â Â Ventura | 195 (0.3%) |
| Â Â Â Â Ventura County | 1,475 (2.0%) |
| Â Â Â Â Yolo | 195 (0.3%) |
| Â Â Â Â Yolo County | 1,338 (1.8%) |
| Â Â Â Â Yuba | 181 (0.2%) |
| Â Â Â Â Yuba County | 1,185 (1.6%) |
| new_infections | 19 (5, 104) |
| Â Â Â Â Unknown | 10,638 |
| new_recovered | 20 (5, 106) |
| Â Â Â Â Unknown | 10,638 |
| count_susceptible | 1,595 (348, 9,496) |
| Â Â Â Â Unknown | 10,638 |
| current_infected | 22 (5, 118) |
| Â Â Â Â Unknown | 10,638 |
| cumulative_infected | 203 (42, 1,227) |
| Â Â Â Â Unknown | 10,638 |
| cumulative_recovered | 169 (34, 1,055) |
| Â Â Â Â Unknown | 10,638 |
| new_unrecovered | 2 (0, 10) |
| Â Â Â Â Unknown | 10,638 |
| cumulative_unrecovered | 15 (3, 98) |
| Â Â Â Â Unknown | 10,638 |
| new_severe | 0 (0, 2) |
| Â Â Â Â Unknown | 10,638 |
| cumulative_severe | 2 (0, 13) |
| Â Â Â Â Unknown | 10,638 |
| age_category | |
| Â Â Â Â 0-17 | 16,099 (25%) |
| Â Â Â Â 18-49 | 17,905 (28%) |
| Â Â Â Â 50-64 | 15,643 (24%) |
| Â Â Â Â 65+ | 15,241 (23%) |
| Â Â Â Â Unknown | 10,638 |
| sex | |
| Â Â Â Â FEMALE | 43,057 (57%) |
| Â Â Â Â MALE | 32,469 (43%) |
| race_ethnicity | |
| Â Â Â Â 1 | 13,295 (20%) |
| Â Â Â Â 2 | 8,330 (13%) |
| Â Â Â Â 3 | 7,733 (12%) |
| Â Â Â Â 4 | 9,451 (15%) |
| Â Â Â Â 5 | 4,393 (6.8%) |
| Â Â Â Â 6 | 9,486 (15%) |
| Â Â Â Â 7 | 12,200 (19%) |
| Â Â Â Â Unknown | 10,638 |
| dt_diagnosis | 2022-09-30 to 2023-05-06 |
| Â Â Â Â Unknown | 10,638 |
| population | 2,786 (565, 16,584) |
| prevalence | 19 (4, 36) |
| Â Â Â Â Unknown | 10,638 |
| incidence | 1.62 (0.44, 2.66) |
| Â Â Â Â Unknown | 10,638 |
| dt_admin | 2020-08-04 to 2023-08-26 |
| Â Â Â Â Unknown | 64,888 |
| total_partial_vaccinated | 706 (72, 5,543) |
| Â Â Â Â Unknown | 64,888 |
| cumulative_fully_vaccinated | 4,787 (221, 45,769) |
| Â Â Â Â Unknown | 64,888 |
| cumulative_at_least_o_ne_dose | 5,888 (434, 52,368) |
| Â Â Â Â Unknown | 64,888 |
| cumulative_unvaccinated | 9,105 (1,795, 44,266) |
| Â Â Â Â Unknown | 64,888 |
| cumulative_up_to_date_vax | 2 (0, 529) |
| Â Â Â Â Unknown | 64,888 |
| quarter | 2020-07-01 to 2023-07-01 |
| Â Â Â Â Unknown | 64,888 |
| infection_rate_by_county | 1,618 (438, 2,657) |
| Â Â Â Â Unknown | 10,638 |
| 1 n (%); Median (IQR); Range | |
#second table using formattable howing descriptive statistics of simulated flu outbreak in entire California and COVID 19 vaccination rate
# using new_joint data frame
formattable(head(new_final_joint_data, 10), list(
col.names = gsub("_", " ", names(new_final_joint_data)),
caption = "Portion of Summary Statistic of joint simulated data set from California and vaccination rates of COVID 19"
))
| county | new_infections | new_recovered | count_susceptible | current_infected | cumulative_infected | cumulative_recovered | new_unrecovered | cumulative_unrecovered | new_severe | cumulative_severe | age_category | sex | race_ethnicity | dt_diagnosis | population | prevalence | incidence | dt_admin | total_partial_vaccinated | cumulative_fully_vaccinated | cumulative_at_least_o_ne_dose | cumulative_unvaccinated | cumulative_up_to_date_vax | quarter | infection_rate_by_county |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Alameda County | 75 | 119 | 45925 | 77 | 196 | 119 | 2 | 2 | 0 | 0 | 0-17 | FEMALE | 1 | 2022-10-10 | 46000 | 0.4260870 | 0.1630435 | NA | NA | NA | NA | NA | NA | NA | 163.0435 |
| Alameda County | 76 | 77 | 45849 | 76 | 272 | 196 | 0 | 2 | 0 | 0 | 0-17 | FEMALE | 1 | 2022-10-16 | 46000 | 0.5913043 | 0.1652174 | NA | NA | NA | NA | NA | NA | NA | 165.2174 |
| Alameda County | 89 | 75 | 45760 | 90 | 361 | 271 | 1 | 3 | 0 | 0 | 0-17 | FEMALE | 1 | 2022-10-24 | 46000 | 0.7847826 | 0.1934783 | NA | NA | NA | NA | NA | NA | NA | 193.4783 |
| Alameda County | 54 | 88 | 45706 | 56 | 415 | 359 | 2 | 5 | 0 | 0 | 0-17 | FEMALE | 1 | 2022-10-27 | 46000 | 0.9021739 | 0.1173913 | NA | NA | NA | NA | NA | NA | NA | 117.3913 |
| Alameda County | 68 | 55 | 45638 | 69 | 483 | 414 | 1 | 6 | 1 | 1 | 0-17 | FEMALE | 1 | 2022-11-10 | 46000 | 1.0500000 | 0.1478261 | NA | NA | NA | NA | NA | NA | NA | 147.8261 |
| Alameda County | 66 | 67 | 45572 | 68 | 549 | 481 | 2 | 8 | 0 | 1 | 0-17 | FEMALE | 1 | 2022-11-15 | 46000 | 1.1934783 | 0.1434783 | NA | NA | NA | NA | NA | NA | NA | 143.4783 |
| Alameda County | 195 | 66 | 45377 | 197 | 744 | 547 | 2 | 10 | 1 | 2 | 0-17 | FEMALE | 1 | 2022-11-19 | 46000 | 1.6173913 | 0.4239130 | NA | NA | NA | NA | NA | NA | NA | 423.9130 |
| Alameda County | 339 | 195 | 45038 | 341 | 1083 | 742 | 2 | 12 | 0 | 2 | 0-17 | FEMALE | 1 | 2022-11-29 | 46000 | 2.3543478 | 0.7369565 | NA | NA | NA | NA | NA | NA | NA | 736.9565 |
| Alameda County | 160 | 334 | 44878 | 167 | 1243 | 1076 | 7 | 19 | 0 | 2 | 0-17 | FEMALE | 1 | 2022-11-29 | 46000 | 2.7021739 | 0.3478261 | NA | NA | NA | NA | NA | NA | NA | 347.8261 |
| Alameda County | 341 | 166 | 44537 | 342 | 1584 | 1242 | 1 | 20 | 0 | 2 | 0-17 | FEMALE | 1 | 2022-12-09 | 46000 | 3.4434783 | 0.7413043 | NA | NA | NA | NA | NA | NA | NA | 741.3043 |
#One print quality plot or chart as requested in scenario ##For each visual, include; Code used to generate visual,Legend (if necessary),1-2 sentence interpretation
# A plot of county against new infection
# new_final_joint_data is your dataframe
library(dplyr)
# Filter out rows with missing values in new_infection or infection_rate_county
# Create the scatter plot using the filtered data
ggplot(df_ca_vax_rates, aes(x = "Cumulative Fully Vaccinated", y = "Estimated Population")) +
geom_point(color = "skyblue") +
labs(title = "Correlation between Estimate Total Population and Cumulative Fully Vaccinated Persons",
x = "Cumulative Fully Vaccinated",
y = "Estimated Total Population") +
theme_minimal()
# A plot of county against new infection
library(dplyr)
# new_final_joint_data is the dataframe
new_final_joint_data_summary <- new_final_joint_data %>%
group_by(county) %>%
summarise(total_new_infections = sum(new_infection))
#After summarizing the data, you can use the new dataframe `new_final_joint_data_summary` to create the bar plot:
ggplot(new_final_joint_data_summary, aes(x = county, y = total_new_infections)) +
geom_bar(stat = "identity", fill = "skyblue") +
labs(title = "New Infections by County",
x = "County",
y = "New Infections") +
theme_minimal()
library(tidyverse)
ggplot(new_final_joint_data_summary, aes(x = county, y = total_new_infections)) +
geom_bar(stat = "identity", fill = "skyblue") +
labs(title = "Number of New Infections by County in California",
x = "County",
y = "New Infections",
subtitle = "county in USA and cases are persons infected",
caption="Data from a simulated California flu season joint with regional vaccination") +
theme_minimal()
# interpretation; there is no specific pattern nor correlation for number of new infections of flu by county
df_plot <- new_final_joint_data %>%
filter(sex=="FEMALE", age_category=="0-17") %>%
select(county, age_category,sex, new_infections, new_recovered,infection_rate_by_county)
#Interpretation