-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCOVID19_Italy_Spain_Korea
More file actions
73 lines (57 loc) · 2.29 KB
/
COVID19_Italy_Spain_Korea
File metadata and controls
73 lines (57 loc) · 2.29 KB
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
require(RCurl)
require(foreign)
require(tidyverse) # To tip the df from long row of dates to cols (pivot_longer())
x = getURL("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv")
corona = (read_csv(x)
%>% pivot_longer(cols = -c(`Province/State`, `Country/Region`, Lat, Long),
names_to = "date",
values_to = "cases")
%>% select(`Country/Region`, date, cases)
%>% mutate(date=as.Date(date,format="%m/%d/%y"))
%>% drop_na(cases)
%>% rename(country="Country/Region")
)
cc <- (corona
%>% filter(country %in% c("Italy","Spain", "Korea, South"))
)
ccw <- (cc
%>% pivot_wider(names_from="country",values_from="cases")
%>% filter(cumsum(Italy>0 | Spain>0)>=5)
)
plot(ccw$date, ccw$Italy, type="l", lwd=3,
ylab='',
xlab='',
log='y',
col=5,
axes=FALSE,
main = "Log-lin cumulative COVID-19 cases in Italy and Spain v South Korea",
cex.main=0.9)
at1 <- seq(min(ccw$date), max(ccw$date)+1, by=2);
axis.Date(1, at=at1, format="%b %d", las=2, cex.axis=0.7)
at2 <- 2^seq(1,30,by=1)
axis(side=2, at2, cex.axis=0.7)
abline(h=at2, lty=2, col="grey90") # Add faint grid lines
abline(v=at1, lty=2, col="grey90") # Add faint grid lines
lines(ccw$date, ccw$`Korea, South`, lwd=3, col=4, lty=3)
lines(ccw$date, ccw$Spain, lwd=3, col=2)
legend(ccw$date[1], 15000, legend=c("Korea", "Italy", "Spain"),
col=c(4, 5, 2), lty=c(3,1,1), lwd=3, cex=0.8,
box.lty=0)
plot(ccw$date, ccw$Italy, type="l", lwd=3,
ylab='',
xlab='',
xaxt="n",
col=5,
cex.axis=0.7,
las=2,
main = "COVID-19 cumulative cases in Italy & Spain v South Korea",
cex.main=0.9)
at1 <- seq(min(ccw$date), max(ccw$date)+1, by=2);
axis.Date(1, at=at1, format="%b %d", las=2, cex.axis=0.7)
lines(ccw$date, ccw$Spain, lwd=3, col=2)
lines(ccw$date, ccw$`Korea, South`, lwd=3, lty=3, col=4)
legend(ccw$date[1], 15000, legend=c("Korea", "Italy", "Spain"),
col=c(4, 5, 2), lty=c(3,1,1), lwd=3, cex=0.8,
box.lty=0)
abline(v=at1, lty=2, col="grey90") # Add faint grid lines
abline(h=seq(0,max(ccw$Italy),5000), lty=2, col="grey90") # Add faint grid lines