-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path_targets.R
138 lines (131 loc) · 4.29 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# _targets.R
# see https://github.com/ropensci/targets/discussions/1297 for long discussion
library(targets)
library(tarchetypes)
lapply(
list.files(
"R",
pattern = "^z_.*\\.R$",
full.names = TRUE
),
source
)
targets::tar_option_set(
packages = c(
"openalexR",
"knitr",
"dplyr",
"ggplot2",
"IPBES.R"
)
)
# if (FALSE) {
# #### Dynamic Branching
# list(
# tar_files_input(
# name = files,
# files = list.files(
# file.path(
# "input"
# ),
# pattern = "\\.csv$",
# full.names = TRUE
# )
# ),
# tar_target(bibliography, load_bibliography(files), pattern = map(files)),
# tar_target(metrics, get_bibliography_measures(bibliography), pattern = map(bibliography)),
# tar_target(figure_pub_year, plot_publication_year(bibliography), pattern = map(bibliography)),
# tar_target(figure_oa_status, plot_oa_status(bibliography), pattern = map(bibliography)),
# tar_target(figure_top_journals_data, plot_top_journals_data(bibliography), pattern = map(bibliography)),
# tar_target(figure_top_journals, plot_top_journals(figure_top_journals_data), pattern = map(figure_top_journals_data)),
# tar_target(figure_top_country_data, plot_top_country_data(bibliography), pattern = map(bibliography)),
# tar_target(figure_top_country, plot_top_country(figure_top_country_data), pattern = map(figure_top_country_data)),
# tar_target(figure_types_data, plot_types_data(bibliography), pattern = map(bibliography)),
# tar_target(
# combined_data,
# list(
# bibliography = bibliography,
# metrics = metrics,
# figure_pub_year = figure_pub_year,
# figure_oa_status = figure_oa_status,
# figure_top_journals_data = figure_top_journals_data,
# figure_top_journals = figure_top_journals,
# figure_top_country_data = figure_top_country_data,
# figure_top_country = figure_top_country,
# figure_types_data = figure_types_data
# ),
# pattern = map(
# files,
# bibliography,
# metrics,
# figure_top_journals_data,
# figure_top_journals,
# figure_top_country_data,
# figure_top_country,
# figure_pub_year,
# figure_oa_status
# )
# )
# )
# } else {
#### Static Branching
list(
tarchetypes::tar_map(
values = data.frame(
files = list.files(
path = "input",
pattern = "\\.csv$",
full.names = FALSE
) |>
gsub(
pattern = "\\.csv",
replacement = ""
)
),
tar_target(bibliography, load_bibliography(files)),
#
tar_target(metrics, get_bibliography_measures(bibliography)),
#
tar_target(figure_pub_year_data, plot_publication_year_data(bibliography)),
tar_target(figure_pub_year, plot_publication_year(figure_pub_year_data)),
#
tar_target(figure_oa_status_data, plot_oa_status_data(bibliography)),
tar_target(figure_oa_status, plot_oa_status(figure_oa_status_data)),
#
tar_target(figure_top_journals_data, plot_top_journals_data(bibliography)),
tar_target(figure_top_journals, plot_top_journals(figure_top_journals_data)),
#
tar_target(figure_top_country_data, plot_top_country_data(bibliography)),
tar_target(figure_top_country, plot_top_country(figure_top_country_data)),
tar_target(figure_top_country_map, plot_top_country_map(figure_top_country_data)),
#
tar_target(figure_types_data, plot_types_data(bibliography)),
tar_target(figure_types, plot_types(figure_types_data)),
#
tar_target(
combined_data,
list(
bibliography = bibliography,
#
metrics = metrics,
#
figure_pub_year_data = figure_pub_year_data,
figure_pub_year = figure_pub_year,
#
figure_oa_status_dara = figure_oa_status_data,
figure_oa_status = figure_oa_status,
#
figure_top_journals_data = figure_top_journals_data,
figure_top_journals = figure_top_journals,
#
figure_top_country_data = figure_top_country_data,
figure_top_country = figure_top_country,
figure_top_country_map = figure_top_country_map,
#
figure_types_data = figure_types_data,
figure_types = figure_types
)
)
)
)
# }