-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCovid-19_Analysis.Rmd
169 lines (123 loc) · 4.67 KB
/
Covid-19_Analysis.Rmd
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
---
title: "Covid-19 Analysis and Prediction"
author: "Arushi Sharma"
date: "3/14/2020"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r message=FALSE}
#Importing all required libraries
library(dplyr)
library(ggplot2)
library(tidyverse)
library(arsenal)
library(caret)
library(wordcloud)
```
```{r}
#Importing dataset
covid19 <- readr :: read_csv("novel-corona-virus-2019-dataset/covid_19_data.csv")
head(covid19, 10)
tail(covid19, 10)
```
```{r}
#summary of the data
summary(covid19)
```
```{r}
#Finding deaths by country
covid19 %>% distinct(`Country/Region`) %>% count()
#%>% filter(Deaths > 0) %>% count(Deaths)
```
```{r Most_affected_countries,warning=FALSE}
tot <- covid19 %>%
filter(ObservationDate == "03/26/2020") %>%
group_by(`Country/Region`) %>%
summarise(sm= sum(Confirmed)) %>%
summarise(sm= sum(sm))
filtered <- covid19 %>% filter(ObservationDate == "03/26/2020") %>%
group_by(`Country/Region`) %>%
summarise(n=sum(Confirmed)) %>%
arrange((n)) %>%
tail(5)
ggplot(filtered) + aes(x=reorder(`Country/Region`,-n),n) +
geom_col() +
geom_col(stat = "identity",fill = "darkolivegreen") +
labs(title = " Reported cases in worst affected countries ") +
xlab("Country") +
ylab("Number of reported cases ") +
geom_text(aes(label=n), vjust=.001, color = "black")
```
```{r}
(covid19 %>% filter(ObservationDate == "03/26/2020") %>%
filter(`Country/Region` == "US") %>% summarise(sum(Confirmed)) )/tot
```
```{r message=FALSE}
covid19 %>% filter(`Country/Region` == "US") %>%
filter(ObservationDate == "03/26/2020") %>%
group_by(`Province/State`) %>%
summarise(n=sum(Confirmed)) %>%
arrange((n)) %>% tail(5) %>%
ggplot() + aes(x=reorder(`Province/State`,-n),n) +
geom_col() +geom_col(stat = "identity",fill = "darkolivegreen") +
labs(title = " Reported cases in worst affected Province/State of US ") +
xlab("Province/State of US ") +ylab("Number of reported cases ") +
geom_text(aes(label=n), vjust=.001, color = "black")
```
```{r}
covid_cases <- covid19 %>% filter(ObservationDate == "03/26/2020") %>%
group_by(`Country/Region`) %>%
summarise(confirmed_cases=sum(Confirmed),Casualities=sum(Deaths),Recovered_cases=sum(Recovered)) %>%
arrange(desc(confirmed_cases)) %>% head(5)
covid_cases
#calculating the recovery rate
covid_cases <- covid_cases %>% mutate(recovered_ratio = Recovered_cases/confirmed_cases)
covid_cases
covid_mean <- covid19 %>% filter(ObservationDate == "03/26/2020") %>%
summarise(confirmed_cases=sum(Confirmed),Casuality=sum(Deaths),Recovered_cases=sum(Recovered)) %>%
arrange(desc(confirmed_cases))
covid_mean
```
```{r}
covid19 %>% group_by(ObservationDate) %>%
summarise(datewise = sum(Confirmed)) %>%
ggplot(aes(x=ObservationDate, y=datewise, group=1)) +
geom_line(col="darkolivegreen") + theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
labs(title = " Plot of Total Reported cases for the month of January-March 2020 ") +
xlab("Observed Date ") +ylab("Number of reported cases ")
```
```{r}
covid19 %>% filter(grepl('^01/', ObservationDate)) %>% group_by(ObservationDate) %>%
summarise(datewise = sum(Confirmed)) %>%
ggplot(aes(x=ObservationDate, y=datewise, group=1)) +
geom_line(col = "black") +labs(title="Reported cases in the month of January",x="Date", y = "Number of cases") +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
```
```{r}
covid19 %>% filter(grepl('^02/', ObservationDate)) %>% group_by(ObservationDate) %>%
summarise(datewise = sum(Confirmed)) %>%
ggplot(aes(x=ObservationDate, y=datewise, group=1)) +
geom_line(col = "black") +labs(title="Reported cases in the month of February",x="Date", y = "Number of cases") +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
```
```{r}
covid19 %>% filter(grepl('^03/', ObservationDate)) %>% group_by(ObservationDate) %>%
summarise(datewise = sum(Confirmed)) %>%
ggplot(aes(x=ObservationDate, y=datewise, group=1)) +
geom_line(col = "black") +labs(title="Reported cases in the month of March",x="Date", y = "Number of cases") +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
```
```{r}
covid_cloud <- covid19 %>%
filter(ObservationDate == "03/26/2020" )
wordcloud(covid_cloud$`Province/State`,covid_cloud$Confirmed,random.order = FALSE,rot.per = .3,
scale = c(5,.8),max.words = 100,colors = brewer.pal(7,"Set1"))
```
```{r}
covid_cloud %>% filter(ObservationDate == "03/26/2020") %>%
group_by(`Country/Region`) %>%
summarise(confirmed_cases=sum(Confirmed),Casulty=sum(Deaths),Recovered_cases=sum(Recovered)) %>%
arrange(desc(confirmed_cases)) %>% head(5)
```