# Load necessary libraries
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
library(tidyr)
# Load the data
data <- read.csv("covid.csv")
# Convert date column to Date format
data$date <- as.Date(data$date)
# Reshape the data for easier plotting
data_long <- data %>%
filter(aged_65_older > 0) %>%
select(date, cardiovasc_death_rate, diabetes_prevalence) %>%
pivot_longer(cols = c(cardiovasc_death_rate, diabetes_prevalence),
names_to = "variable",
values_to = "value")
# Plotting
combined_plot <- ggplot(data_long, aes(x = date, y = value, color = variable)) +
geom_line() +
labs(title = "Cardiovascular Death Rate and Diabetes Prevalence Over Time",
x = "Date",
y = "Rate / Prevalence") +
scale_color_manual(values = c("#0033FF", "#CC3300")) +
facet_wrap(~variable, scales = "free_y") +
coord_cartesian(ylim = c(0, 750)) # Adjust y-axis limits for cardiovascular death rate
# Display plots
print(combined_plot)
