-
Notifications
You must be signed in to change notification settings - Fork 0
/
_targets.R
76 lines (69 loc) · 1.79 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
options(
TARGETS_N_CORES = 35
)
suppressPackageStartupMessages({
library(targets)
library(sf)
})
source("R/1_prep.R", encoding = "UTF-8")
source("R/2_calculate_access.R", encoding = "UTF-8")
if (!interactive()) future::plan(future.callr::callr)
tar_option_set(workspace_on_error = TRUE)
list(
tar_target(h3_resolutions, 7:9),
tar_target(years, 2010),
tar_target(modes, c("bicycle", "walk")),
tar_target(time_thresholds, c(30, 60, 90)),
tar_target(
pop_units_dataset,
"../../data/acesso_oport_v2/pop_units.rds",
format = "file"
),
tar_target(n_batches, 35),
# 1_prep
tar_target(pop_units, readRDS(pop_units_dataset), iteration = "group"),
tar_target(
batches_by_ttm_size,
get_batches_by_ttm_size(
pop_units,
h3_resolutions[h3_resolutions == 9],
years[years == 2010],
modes[modes == "bicycle"],
n_batches
),
iteration = "group"
),
tar_target(
ttm_paths,
create_ttm_paths(batches_by_ttm_size, h3_resolutions, years, modes),
format = "file_fast",
pattern = cross(batches_by_ttm_size, h3_resolutions, years, modes),
retrieval = "worker",
storage = "worker",
iteration = "list"
),
tar_target(
opportunities_paths,
create_opportunities_paths(batches_by_ttm_size, h3_resolutions, years),
format = "file_fast",
pattern = cross(batches_by_ttm_size, h3_resolutions, years),
retrieval = "worker",
storage = "worker",
iteration = "list"
),
# 2_calculate_access
tar_target(
cumulative_access,
calculate_cum_access(
ttm_paths,
opportunities_paths,
modes,
time_thresholds
),
format = "file_fast",
pattern = map(ttm_paths, cross(opportunities_paths, modes)),
retrieval = "worker",
storage = "worker",
iteration = "list"
)
)