-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_data.R
84 lines (79 loc) · 1.77 KB
/
run_data.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
73
74
75
76
77
78
79
80
81
82
83
84
#' Pipeline for Data Retrieval
#'
#' This pipeline performs data retrieval from various data sources.
#' Data can be saved in a s3 bucket if `SAVE_TO_S3` is set to TRUE.
library(targets)
# Set target options:
tar_option_set(
packages = c(
"xts", "lubridate", "dplyr", "tidyr", "data.table",
"jsonlite", "styler", "visNetwork"
),
memory = "transient",
garbage_collection = TRUE
)
options(dplyr.summarise.inform = FALSE)
# Execute files stored in R/
tar_source(files = "R")
# Saving flag to S3 (TOKEN NEEDED)
SAVE_TO_S3 <- TRUE
# Pipeline
list(
tar_target(
name = data_info_file,
command = "data.yaml",
format = "file"
),
tar_target(
name = challenges_file,
command = "challenges.yaml",
format = "file"
),
tar_target(
name = models_file,
command = "models.yaml",
format = "file"
),
tar_target(
name = data_info,
command = yaml::read_yaml(data_info_file),
),
tar_target(
name = challenges,
command = yaml::read_yaml(challenges_file),
),
tar_target(
name = eurostat,
command = get_data_from_eurostat(data_info),
),
tar_target(
name = yahoo,
command = get_data_from_yahoo(data_info),
),
tar_target(
name = gtrends,
command = get_data_from_google_trends(data_info),
),
tar_target(
name = ember,
command = get_data_from_ember(data_info),
),
tar_target(
name = destatis,
command = get_data_from_destatis(data_info),
),
tar_target(
name = weekend,
command = get_weekend_days(data_info, challenges),
),
tar_target(
name = data,
command = get_data(
data_info, c(eurostat, yahoo, gtrends, ember, destatis, weekend))
),
tar_target(
name = data_saved,
command = save_data(data, challenges, SAVE_TO_S3),
format = "file"
)
)