-
Notifications
You must be signed in to change notification settings - Fork 0
/
_targets.R
116 lines (108 loc) · 3.15 KB
/
_targets.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
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
110
111
112
113
114
library(targets)
library(tarchetypes)
source("R/functions.R")
source("R/helpers.R")
options(tidyverse.quiet = TRUE)
# ggchicklet is not available from CRAN
# install.packages("ggchicklet", repos = "https://cinc.rud.is")
tar_option_set(packages = c("scales", "tidyverse", "ggchicklet", "hrbrthemes",
"janitor"))
owner <- FALSE # set this to FALSE if you are not Thomas Klebel
if (owner) {
# full pipeline for original data
list(
tar_target(
raw_data_file,
"data/raw/results-survey.csv",
format = "file"
),
tar_target(
recoded_disciplines_file,
"data/processed/disciplines_lookup.xlsx",
format = "file"
),
tar_target(
wb_file,
"data/external/world_bank_country_classification.xlsx",
format = "file"
),
tar_target(
label_file,
"data/processed/labels_expanded.csv",
format = "file"
),
tar_target(
var_overview,
create_var_overview(raw_data_file)
),
tar_target(
raw_data,
read_csv(raw_data_file, col_names = FALSE, skip = 1)
),
tar_target(
expanded_labels,
read_csv(label_file, col_types = "cc")
),
tar_target(
recoded_disciplines,
readxl::read_excel(recoded_disciplines_file, na = "NA")
),
tar_target(
wb_countries,
read_clean_wb_countries(wb_file)
),
tar_target(
clean_data,
clean_raw_data(raw_data, wb_countries) %>%
merge_disciplines(recoded_disciplines)
),
tar_target(
shareable_data,
clean_data %>%
select(-X12, -X16, -X89) # remove country and institution information
),
tar_target(
share_data,
write_csv(shareable_data, "data/processed/shareable_data.csv")
),
tar_render(demographics, "analysis-notebooks/01-demography.Rmd"),
tar_render(institutional_context, "analysis-notebooks/02-institutional-context.Rmd"),
tar_render(attitudes, "analysis-notebooks/03-attitudes-towards-promotion-criteria.Rmd"),
tar_render(opinion_vs_practice, "analysis-notebooks/04-opinion-vs-practice.Rmd"),
tar_render(research_vs_policy, "analysis-notebooks/05-research-vs-policies.Rmd"))
} else {
# abbreviated target pipeline for publicly shared data
list(
tar_target(
survey_file,
"data/processed/shareable_data.csv",
format = "file"
),
tar_target(
shareable_data,
read_csv(survey_file)
),
tar_target(
var_overview_file,
"data/processed/var_overview.csv",
format = "file"
),
tar_target(
var_overview,
read_csv(var_overview_file, col_types = "cc")
),
tar_target(
label_file,
"data/processed/labels_expanded.csv",
format = "file"
),
tar_target(
expanded_labels,
read_csv(label_file, col_types = "cc")
),
tar_render(institutional_context, "analysis-notebooks/02-institutional-context.Rmd"),
tar_render(attitudes, "analysis-notebooks/03-attitudes-towards-promotion-criteria.Rmd"),
tar_render(opinion_vs_practice, "analysis-notebooks/04-opinion-vs-practice.Rmd"),
tar_render(research_vs_policy, "analysis-notebooks/05-research-vs-policies.Rmd")
)
}