-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy path.Rhistory
192 lines (192 loc) · 6.47 KB
/
.Rhistory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
install.packages("tidyverse")
install.packages("lubridate")
install.packages("ggplot2")
library(tidyverse)
library(lubridate)
library(ggplot2)
# Load the dataset
covid_data <- read.csv("synthetic_covid_data_realistic.csv")
# Convert Date column to Date type
covid_data$Date <- as.Date(covid_data$Date)
# Growth curve of cases and deaths for each country
covid_data %>%
gather(key = "Condition", value = "Count", Cases, Deaths) %>%
group_by(Country, Condition) %>%
mutate(CumulativeCount = cumsum(Count)) %>%
ggplot(aes(x = Date, y = CumulativeCount, color = Country)) +
geom_line() +
facet_wrap(~Condition, scales = "free_y") +
labs(title = "Growth Curve of COVID-19 Cases and Deaths",
x = "Date",
y = "Cumulative Count") +
theme_minimal()
library(tidyverse)
library(lubridate)
library(ggplot2)
# Load the dataset
covid_data <- read.csv("synthetic_covid_data_realistic.csv")
# Convert Date column to Date type
covid_data$Date <- as.Date(covid_data$Date)
# Vaccination rate visualization
covid_data %>%
select(Country, Date, Vaccination) %>%
group_by(Country) %>%
mutate(PercentageVaccinated = Vaccination / max(Vaccination) * 100) %>%
ggplot(aes(x = Date, y = PercentageVaccinated, color = Country)) +
geom_line() +
labs(title = "COVID-19 Vaccination Progress by Country",
x = "Date",
y = "Percentage of Population Vaccinated") +
theme_minimal()
library(tidyverse)
library(lubridate)
library(ggplot2)
# Load the dataset
covid_data <- read.csv("synthetic_covid_data_realistic.csv")
# Convert Date to Date type and calculate per capita metrics
covid_data$Date <- as.Date(covid_data$Date)
covid_data <- covid_data %>%
mutate(CasesPerCapita = Cases / 100000,
DeathsPerCapita = Deaths / 100000,
VaccinationRate = Vaccination / 100000)
# Plot vaccination rates vs. cases/deaths per capita
ggplot(covid_data, aes(x=VaccinationRate, y=CasesPerCapita, color=Country)) +
geom_point(alpha=0.5) +
geom_smooth(method="lm") +
facet_wrap(~Country, scales="free") +
theme_minimal() +
labs(title="Vaccination Rate vs. Cases Per Capita by Country",
x="Vaccination Rate (per 100,000 people)",
y="Cases Per Capita")
# Additionally, for deaths per capita
ggplot(covid_data, aes(x=VaccinationRate, y=DeathsPerCapita, color=Country)) +
geom_point(alpha=0.5) +
geom_smooth(method="lm") +
facet_wrap(~Country, scales="free") +
theme_minimal() +
labs(title="Vaccination Rate vs. Deaths Per Capita by Country",
x="Vaccination Rate (per 100,000 people)",
y="Deaths Per Capita")
# Save the plots
ggsave("vaccination_vs_cases_per_capita.png", width=10, height=6)
ggsave("vaccination_vs_deaths_per_capita.png", width=10, height=6)
library(tidyverse)
library(lubridate)
library(ggplot2)
# Load the dataset
covid_data <- read.csv("synthetic_covid_data_realistic.csv")
# Convert Date to Date type
covid_data$Date <- as.Date(covid_data$Date)
# Plot total cases and deaths over time for each country
covid_data %>%
gather(key="Condition", value="Count", Cases, Deaths) %>%
ggplot(aes(x=Date, y=Count, color=Country)) +
geom_line() +
facet_wrap(~Condition, scales="free_y") +
theme_minimal() +
labs(title="COVID-19 Cases and Deaths Over Time",
x=NULL, y="Count",
color="Country")
# Save the plot
ggsave("covid_trends_over_time.png", width=10, height=6)
library(tidyverse)
library(lubridate)
library(forecast)
library(ggplot2)
# Load the dataset
covid_data <- read.csv("synthetic_covid_data_realistic.csv")
# Preprocessing
covid_data$Date <- as.Date(covid_data$Date)
selected_country_data <- filter(covid_data, Country == "United States")
# Time Series Decomposition
cases_ts <- ts(selected_country_data$Cases, frequency = 12)
decomposed_cases <- stl(cases_ts, s.window = "periodic")
plot(decomposed_cases)
# Autocorrelation Analysis
acf(cases_ts)
pacf(cases_ts)
# Save the decomposition plot and ACF, PACF plots
ggsave("cases_decomposition.png")
ggsave("cases_acf_pacf.png")
library(tidyverse)
library(lubridate)
library(forecast)
library(ggplot2)
# Load the dataset
covid_data <- read.csv("synthetic_covid_data_realistic.csv")
# Preprocessing
covid_data$Date <- as.Date(covid_data$Date)
vaccination_data <- filter(covid_data, Country == "India") %>%
select(Date, Vaccination) %>%
arrange(Date)
# Create a time series object
vaccination_ts <- ts(vaccination_data$Vaccination, start = c(2020, 1), frequency = 12)
# Split data into training and test sets
train_end <- length(vaccination_ts) * 0.8
train_ts <- window(vaccination_ts, end = train_end)
load("C:/Users/hoang/Downloads/acsnc2022.Rdata")
library(tidyverse)
acsnc <- mutate(acsnc, college = if_else(educ>=16, 1, 0))
statsbycity <- acsnc %>%
group_by(met2023) %>%
summarize(incmean = mean(inctot, na.rm = TRUE),
incsd = sd(inctot, na.rm = TRUE),
collshare = mean(college, na.rm = TRUE),
n = n(),
povertyProportion = mean(inpov, na.rm = TRUE)
)
View(statsbycity)
load("C:/Users/hoang/Downloads/acsnc2022 (1).Rdata")
library(tidyverse)
acsnc <- mutate(acsnc, college = if_else(educ>=16, 1, 0))
statsbycity <- acsnc %>%
group_by(met2023) %>%
summarize(incmean = mean(inctot, na.rm = TRUE),
incsd = sd(inctot, na.rm = TRUE),
collshare = mean(college, na.rm = TRUE),
n = n())
View(statsbycity)
library(tidyverse)
acsnc <- mutate(acsnc, college = if_else(educ>=16, 1, 0))
statsbycity1 <- acsnc %>%
group_by(met2023) %>%
summarize(incmean = mean(inctot, na.rm = TRUE),
incsd = sd(inctot, na.rm = TRUE),
collshare = mean(college, na.rm = TRUE),
n = n())
View(statsbycity1)
statsbycity1 <- acsnc %>%
+ group_by(met2023) %>%
+ summarize(incmean = mean(inctot, na.rm = TRUE),
+ incsd = sd(inctot, na.rm = TRUE),
statsbycity1 <- acsnc %>%
+ group_by(met2023) %>%
+ summarize(incmean = mean(inctot, na.rm = TRUE),
+ incsd = sd(inctot, na.rm = TRUE),
library(tidyverse)
acsnc <- mutate(acsnc, college = if_else(educ>=16, 1, 0))
statsbycity <- acsnc %>%
group_by(met2023) %>%
summarize(incmean = mean(inctot, na.rm = TRUE),
incsd = sd(inctot, na.rm = TRUE),
collshare = mean(college, na.rm = TRUE),
n = n(), inpovMean = mean(inpov, na.rm = TRUE))
View(statsbycity1)
View(statsbycity1)
library(tidyverse)
acsnc <- mutate(acsnc, college = if_else(educ>=16, 1, 0))
statsbycity <- acsnc %>%
group_by(met2023) %>%
summarize(incmean = mean(inctot, na.rm = TRUE),
incsd = sd(inctot, na.rm = TRUE),
collshare = mean(college, na.rm = TRUE),
n = n(),
inpovMean = mean(inpov, na.rm = TRUE))
library(tidyverse)
acsnc <- mutate(acsnc, college = if_else(educ>=16, 1, 0))
statsbycity1 <- acsnc %>%
group_by(met2023) %>%
summarize(incmean = mean(inctot, na.rm = TRUE),
incsd = sd(inctot, na.rm = TRUE),
collshare = mean(college, na.rm = TRUE),
n = n(), inpovMean = mean(inpov, na.rm = TRUE))