-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path_06-compile-reports.R
More file actions
101 lines (76 loc) · 3.05 KB
/
Copy path_06-compile-reports.R
File metadata and controls
101 lines (76 loc) · 3.05 KB
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
# _06-compile-reports.R
source("_00-setup.R")
# compile annual data validation reports for each file in preppedDAta:
root<-stringr::str_remove(dir("./prepped-data"),
".rds")
# trs: skookumchuk 88
# co: victoria topaz 107
# everything else (except h2s): kitimat riverlodge 51
# h2s: pine river gas plant 68
utils::View(root)
# stations that won't compile:
#indices in roots that won't compile:
# bugs<-c()
root_no_bugs<-root[!(1:length(root) %in% bugs)]
utils::View(root_no_bugs)
purrr::walk(root[1:length(root)],
#compile reports for stations without bugs
# root_no_bugs[1:length(root_no_bugs)], #%>% utils::View(.),
# compile for roots with bugs:
# root[bugs],
#compile reports for specific stations:
#root[15],
function(r){
# testing
# (r<-root[1])
# End testing
print(paste0("Compiling for ",
r,
" ..."))
# # RENDER ENTIRE BOOK
bookdown::render_book(
# this will compile all the rmd files listed in _bookdown.yml
".",
"bookdown::gitbook",
output_dir = stringr::str_c("_", r, sep = ""),
params = list(
prepped_data = stringr::str_c("./prepped-data/", r, ".rds", collapse = ""),
year = year_to_validate
) #params
) # render_book
# # RENDER SPECIFIC CHAPTERS
# bookdown::preview_chapter(c("index.Rmd","05-nox.Rmd"),
# output_dir = stringr::str_c("_", r, sep = ""),
# params = list(
# prepped_data = stringr::str_c("./prepped-data/", r, ".rds", collapse = ""),
# year = year_to_validate
# ))
}
)
# need to delete all files 404.html - don't know why these are being generated
files_to_delete <- list.files(
#path = ".",
# path = "R:\\WANSHARE\\EPD\\EPD_SHARED\\MAS\\Air Quality Section\\aq-level2-validation",
path = "C:\\HagaR\\aq-level2-validation",
pattern = "404",
recursive = TRUE,
full.names = TRUE
)
file.remove(files_to_delete)
# # # 2025 - what's below wasn't working for transferring files (wasn't making subdirectories)
# # # so transferred them manually
# list files in the reports
files_to_copy <- dir(
file.path(".",
stringr::str_c("_",
root)),
all.files = TRUE,
full.names = TRUE,
recursive = TRUE
)
#copy files to shared drive
destination<-"R:\\WANSHARE\\EPD\\EPD_SHARED\\MAS\\Air Quality Section\\aq-level2-validation"
file.copy(from = files_to_copy,
to=destination,
overwrite = TRUE,
recursive = TRUE)