# Update filename if needed
df <- read.csv(file.choose())
# Quick check
dim(df)
## [1] 41602 30
names(df)
## [1] "iso_code" "continent"
## [3] "location" "date"
## [5] "new_cases_smoothed_per_million" "new_deaths_smoothed_per_million"
## [7] "total_cases_per_million" "total_deaths_per_million"
## [9] "stringency_index" "reproduction_rate"
## [11] "total_vaccinations_per_hundred" "people_vaccinated_per_hundred"
## [13] "people_fully_vaccinated_per_hundred" "hospital_beds_per_thousand"
## [15] "life_expectancy" "cardiovasc_death_rate"
## [17] "diabetes_prevalence" "gdp_per_capita"
## [19] "population_density" "median_age"
## [21] "aged_65_older" "human_development_index"
## [23] "population" "country_group"
## [25] "year" "month"
## [27] "year_month" "case_fatality_rate"
## [29] "vax_coverage" "days_since_start"
p1 <- df %>%
group_by(country_group) %>%
summarise(avg_cfr = mean(case_fatality_rate, na.rm = TRUE)) %>%
ggplot(aes(x = reorder(country_group, avg_cfr), y = avg_cfr, fill = country_group)) +
geom_col() +
coord_flip() +
scale_fill_manual(values = c("#00BFC4","#F8766D","#7CAE00")) +
scale_y_continuous(labels = percent) +
labs(title = "Average Case Fatality Rate by Country Group",
x = "", y = "Fatality Rate")
p1
ggsave("plot1.png", p1, width = 8, height = 5)
p2 <- ggplot(df, aes(x = vax_coverage, y = case_fatality_rate, color = country_group)) +
geom_point(alpha = 0.3) +
geom_smooth(method = "lm", se = FALSE) +
scale_color_manual(values = c("#00BFC4","#F8766D","#7CAE00")) +
labs(title = "Vaccination Coverage vs Fatality Rate",
x = "Vaccination Coverage",
y = "Fatality Rate")
p2
ggsave("plot2.png", p2, width = 8, height = 5)
p3 <- ggplot(df, aes(x = stringency_index, y = new_cases_smoothed_per_million, color = country_group)) +
geom_point(alpha = 0.3) +
geom_smooth(method = "lm", se = FALSE) +
scale_color_manual(values = c("#00BFC4","#F8766D","#7CAE00")) +
labs(title = "Stringency vs Case Burden",
x = "Stringency Index",
y = "Cases per Million")
p3
ggsave("plot3.png", p3, width = 8, height = 5)
p4 <- ggplot(df, aes(x = reproduction_rate, y = new_cases_smoothed_per_million, color = country_group)) +
geom_point(alpha = 0.3) +
geom_smooth(method = "lm", se = FALSE) +
scale_color_manual(values = c("#00BFC4","#F8766D","#7CAE00")) +
labs(title = "Reproduction Rate vs Cases",
x = "Reproduction Rate",
y = "Cases per Million")
p4
ggsave("plot4.png", p4, width = 8, height = 5)
p5 <- df %>%
group_by(country_group) %>%
summarise(avg_cases = mean(new_cases_smoothed_per_million, na.rm = TRUE)) %>%
ggplot(aes(x = reorder(country_group, avg_cases), y = avg_cases, fill = country_group)) +
geom_col() +
coord_flip() +
scale_fill_manual(values = c("#00BFC4","#F8766D","#7CAE00")) +
labs(title = "Average Cases per Million by Group",
x = "", y = "Cases")
p5
ggsave("plot5.png", p5, width = 8, height = 5)
Plots are saved as PNG files. Use them in Canva.