-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path_targets.R
67 lines (62 loc) · 1.93 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
# if (!requireNamespace("odf"))
# remotes::install_github("mtennekes/odf")
# #install.packages('targets')
#
# remotes::install_github("r-spatial/leafsync") # requires the github version of leafsync
# remotes::install_github("mtennekes/tmap") # latest github version of tmap required to improve the popups
#
library(targets)
source("R/maps_utils.R", encoding = "UTF-8")
tar_option_set(
packages = c(
"tidyverse",
"tmaptools",
"tmap",
"odf",
"sf",
"htmltools",
"htmlwidgets",
"leafsync"
)
)
list(
tar_target(langue, c("fr-FR", "en-US")),
tar_target(inflows, c(TRUE, FALSE)),
tar_target(before_after, 1:2),
tar_target(vizLink, 'https://inseefrlab.github.io/lockdown-maps-R/'),
tar_target(totals, get_residents()),
tar_target(infos, unlist(HTMLInfos(vizLink, inflows, langue))),
tar_target(htmls_files, html_names(inflows, langue)$name, pattern = cross(inflows,langue)),
tar_target(htmls_langue, rep(langue, 2)),
tar_target(dm_centroid, departement_centroids()),
tar_target(ODs, get_ODs(), iteration = "list"),
tar_target(
ODsGeo,
get_ODsGeo(ODs, dm_centroid),
pattern = map(ODs),
iteration = "list"
),
tar_target(tmaps,
list(tmaps = build_tmap(
ODsGeo[[before_after]], totals, inflows, langue, title(before_after, inflows, langue)
)),
pattern = map(cross(
before_after, inflows, langue
))),
tar_target(synctmaps,
sync_tmaps(tmaps), iteration = 'list'),
tar_target(
savehtmls,
save_tags(
{
tmap_mode('view')
if (!dir.exists("html")) dir.create("html")
print(synctmaps, show = FALSE, full.height = TRUE) %>%
htmlwidgets::appendContent(htmltools::HTML(infos))},
htmls_files,
htmls_langue
),
pattern = map(synctmaps, infos, htmls_files, htmls_langue),
format = "file"
)
)