-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_targets.R
124 lines (99 loc) · 2.32 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
# === Prepare locs: targets workflow --------------------------------------
# Alec Robitaille
# Functions ---------------------------------------------------------------
targets::tar_source('R')
# Renv --------------------------------------------------------------------
snapshot()
# Options -----------------------------------------------------------------
tar_option_set(workspace_on_error = FALSE,
format = 'qs')
# Targets -----------------------------------------------------------------
list(
tar_target(
meta,
metadata()
),
# Note: this prepare locs workflow only processes files if it finds they
# exist at the specified path in metadata.
tar_target(
checkmeta,
check_meta(meta),
cue = tar_cue('always')
),
tar_target(
deploy_paths,
checkmeta$deployment,
pattern = map(checkmeta)
),
tar_target(
paths,
checkmeta$path,
pattern = map(checkmeta),
format = 'file'
),
tar_target(
reads,
read_data(paths, checkmeta, deploy),
pattern = map(paths, checkmeta, deploy)
),
tar_target(
deploy,
read_deployment(deploy_paths),
pattern = map(deploy_paths)
),
tar_target(
renames,
set_colnames(
DT = reads,
x_long = checkmeta$x_long,
y_lat = checkmeta$y_lat,
id = checkmeta$id,
date = checkmeta$date,
time = checkmeta$time,
datetime = checkmeta$datetime,
extracols = checkmeta$extracols,
extracols_names = checkmeta$extracols_names
),
pattern = map(reads, checkmeta)
),
tar_target(
dates,
prep_dates(renames, checkmeta$tz),
pattern = map(renames, checkmeta)
),
tar_target(
checks,
check_locs(dates, checkmeta, deploy),
pattern = map(dates, checkmeta, deploy)
),
tar_target(
checkflags,
setcolorder(checks[, .(name = name[[1]], .N), flag], c(2, 1, 3)),
pattern = map(checks)
),
tar_target(
filters,
checks[is.na(flag)][, flag := NULL],
pattern = map(checks)
),
tar_target(
coords,
project_locs(filters, checkmeta$epsgin, checkmeta$epsgout),
pattern = map(filters, checkmeta)
),
tar_target(
exports,
export_csv(coords, 'output', checkmeta$splitBy, checkmeta$extracols),
pattern = map(coords, checkmeta)
),
tar_target(
readme,
file.path('README.Rmd'),
format = 'file'
),
tar_target(
render_readme,
{exports; checkflags; render(readme); file.remove('README.html'); 'README.md'},
format = 'file'
)
)