forked from CoronaNetDataScience/corona_tscs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_spreadsheets.R
54 lines (33 loc) · 1.15 KB
/
create_spreadsheets.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
38
39
40
41
42
43
44
45
46
47
48
49
# load R data and create spreadsheets for all countries
require(dplyr)
require(tidyr)
require(readr)
require(googlesheets4)
require(googledrive)
require(lubridate)
# identify
drive_auth()
sheets_auth(token = drive_token())
# date infection started
# we assume
seq_days <- seq(ymd('2019-12-15'),today(),by="days")
num_days <- length(seq_days)
niehaus_data <- read_csv("data/data_niehaus/03_21_20_0105am_wep.csv")
# iterate over countries
over_countries <- lapply(unique(niehaus_data$country), function(c) {
this_country <- tibble(country=c,
day=seq_days,
ra_name="",
num_tested=rep("",num_days),
link_num_tested=rep("",num_days))
# create new gs sheet
this_country_sheet <- sheets_create(name=paste0(c,"_coronavirus_data"),sheets=c)
# output data to sheet
this_country_sheet <- sheets_write(this_country,ss=this_country_sheet,sheet=c)
#drive_mkdir(paste0("panoptes_pdf_upload/",c))
Sys.sleep(20)
# # move to google drive folder
#
# drive_mv(file=as_sheets_id(this_country_sheet),
# path="~/coronavirus_data/")
})