-
Notifications
You must be signed in to change notification settings - Fork 26
/
main.R
44 lines (21 loc) · 878 Bytes
/
main.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
source(here::here("R/setup.R"))
# Iterator functions ------------------------------------------------------
create_reports <- function(...) {
current <- tibble::tibble(...)
loc <- here::here("R/rmarkdown/report_master.Rmd")
rmarkdown::render(
input = loc,
output_file = paste0(current$branch, "_", this_year, "_", this_month ,".pdf"),
output_dir = paste0("finished_reports"),
intermediates_dir = "/finished_reports/tex",
clean = T,
params = list(branch = current$branch,
month = this_month,
year = this_year)
)
}
# Wrap our fn in the possibly function, to catch errors
maybe_create_reports <- purrr::possibly(.f = create_reports, otherwise = NULL)
# Main iterator -----------------------------------------------------------
input_data %>%
purrr::pwalk(maybe_create_reports)