forked from sueddeutsche/corona_automated_charts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.R
72 lines (48 loc) · 2.08 KB
/
main.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# main.R
#
# This is the main.R - that is called by the cronjob to run all scripts
#
print(paste0("+++ Started at: ", Sys.time()))
# loading libraries with needs. Install it first, if needed:
# install.packages("needs")
library(needs)
needs(
tidyverse, magrittr, rvest, clipr,
zoo, scales, tidyr, readxl, DatawRappr,lubridate,
jsonlite, countrycode, stringr, dplyr, googlesheets4, lubridate, here
)
# manually set working directory, to get the right references for the scripts
# if you're a pro, you could use here::here()
# setwd("~/scripts/corona")
# create timestamp for updating the information in Datawrapper, wrangle it to German date format.
TIMESTAMP_NOW <- format(Sys.time(), "%d.%m.%Y %H:%M Uhr")
# set API-Key for Datawrapper globally:
API_KEY <- "INSERT YOUR DATWRAPPER-API KEY HERE"
# load misc functions
source("functions/misc.R")
print(">>> Loading data")
source("functions/input/read_data.R")
print(">>> Creating Dashboard")
source("functions/production/dashboard/create_dashboard.R")
print(">>> Creating Charts")
# Table with Germany, Italy, China and World
source("functions/production/charts/table_cases_deaths_recovered.R")
# Table with all Cases world-wide
source("functions/production/charts/table_world_cases_deaths.R")
# Line-chart with cum-sum of Cases: World vs. China
source("functions/production/charts/line_cases.R")
# Area-chart with cum-sums: Cases vs. Cured vs. Deaths worldwide
source("functions/production/charts/area_cases_vs_cured.R")
# Bar-chart with percentages: Deathrates by country
source("functions/production/charts/bar_deathrate.R")
# Line-chart: Comparison of Cases between Corona and Sars in days since first occurence
source("functions/production/charts/line_corona_vs_sars.R")
print(">>> Creating Maps")
source("functions/production/maps/get_geographical_data.R")
# map Cases in Bavarian counties
source("functions/production/maps/map_bavaria_counties.R")
print(">>> Creating Output")
# create output datasets
source("functions/create_output_data.R")
print(paste("+++ Finished Script at", Sys.time()))
print(paste("+++++++++++++++++++++++++++++++++"))