-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCOVID19 CASES US SPA ITA US SK
More file actions
109 lines (85 loc) · 3.57 KB
/
COVID19 CASES US SPA ITA US SK
File metadata and controls
109 lines (85 loc) · 3.57 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
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
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_covid19_confirmed_global.csv")
corona <- read.csv(textConnection(x))
corona = (read_csv(x)
%>% pivot_longer(cols = -c(`Province/State`, `Country/Region`, Lat, Long),
names_to = "date",
values_to = "cases")
%>% select(`Province/State`, `Country/Region`, date, cases)
%>% mutate(date=as.Date(date,format="%m/%d/%y"))
%>% drop_na(cases)
%>% rename(provinces=`Province/State`, country=`Country/Region`)
)
cc <- (corona
%>% filter(country %in% c("Italy","Spain", "Korea, South","US"))
)
ccw <- (cc
%>% pivot_wider(names_from="country",values_from="cases")
%>% filter(cumsum(Italy>0 & Spain>0)>=2)
)
china <- corona[corona$country=='China',]
provinces <- c('Hubei', 'Guangdong', 'Henan', 'Zhejiang', 'Hunan', 'Anhui',
'Jiangxi','Shandong','Jiangsu','Sichuan','Heilongjiang','Hebei',
'Fujian','Guangxi','Shaanxi','Yunnan','Hainan','Guizhou','Shanxi',
'Gansu','Hong Kong','Liaoning','Jilin','Xinjiang','Inner Mongolia',
'Ningxia','Qinghai','Macau','Tibet')
china_prov <- china[is.element(china$provinces,provinces),]
ccchina <- china_prov[,2:4]
temp <- aggregate(ccchina[ ,3], FUN="sum", by=list(as.Date(ccchina$date)))
ccchina[1:nrow(temp),2:3] <- temp
ccchina <- ccchina[1:nrow(temp),]
ccw_china <- (ccchina
%>% pivot_wider(names_from=country,values_from="cases")
%>% filter(China>1)
)
plot(ccw$date, ccw$US, type="l", lwd=3, lty=1,
ylab='',
xlab='',
log='y',
col=1,
axes=FALSE,
main = "Log-lin cumulative COVID-19 cases in Italy, Spain, US v SK & China",
cex.main=0.9,
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, las=2)
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$US, type="l", lwd=3, col=1)
lines(ccw$date, ccw$Italy, type="l", lwd=3, col=4)
lines(ccw$date, ccw$`Korea, South`, lwd=3, col=5, lty=3)
lines(ccw$date, ccw$Spain, lwd=3, col=2)
lines(ccw_china$date, ccw_china$China, lwd=3, lty= 3, col=7)
legend(ccw$date[1], 5000,
legend=c("China", "Korea", "Italy", "Spain", "US"),
col=c(7,5,4,2,1), lty=c(3,3,1,1,1), lwd=3, cex=0.8,
box.lty=0)
plot(ccw$date, ccw$US, type="l", lwd=3, lty=1,
ylab='',
xlab='',
col=1,
axes=F,
cex.axis=0.7,
las=2,
main = "Cumulative COVID-19 cases in Italy, Spain, US v SK & China",
cex.main=0.9,
bty='l')
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 <- seq(0, 1000000, by=20000);
axis(side=2, at2, cex.axis=0.7, las=2)
abline(v=at1, lty=2, col="grey90") # Add faint grid lines
abline(h=at2, lty=2, col="grey90") # Add faint grid lines
lines(ccw$date, ccw$US, lwd=3, col=1)
lines(ccw$date, ccw$Italy, lwd=3, col=4)
lines(ccw$date, ccw$Spain, lwd=3, col=2)
lines(ccw$date, ccw$`Korea, South`, lwd=3, lty=3, col=5)
lines(ccw_china$date, ccw_china$China, lwd=3, lty=3, col=7)
legend(ccw$date[1], 200000,
legend=c("China","Korea", "Italy", "Spain", "US"),
col=c(7,5,4, 2, 1), lty=c(3,3,1,1,1), lwd=3, cex=0.8,
box.lty=0)