forked from covid19datahub/COVID19
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathds_canada_ca.R
37 lines (28 loc) · 822 Bytes
/
ds_canada_ca.R
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
canada_ca <- function(cache,level){
# Author: Paolo Montemurro 02/05/2020 - [email protected]
# === source === #
url <- "http://health-infobase.canada.ca/src/data/covidLive/covid19.csv"
# === download === #
x <- read.csv(url, cache = cache, na.strings = c("","N/A"))
# === formatting === #
x <- map_data(x, c(
"date",
"prname" = "name",
"pruid" = "uid",
"numdeaths" = "deaths",
"numconf" = "confirmed",
"numtested" = "tests",
"numrecover" = "recovered"
))
x$date <- as.Date(x$date, format = "%d-%m-%Y")
# === cleaning === #
# deleting non territories
x <- x[x$name!="Repatriated travellers",]
# creating levels
if(level==1)
x <- x[x$name=="Canada",]
if(level==2)
x <- x[x$name!="Canada",]
# return
return(x)
}