-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathrun_all.R
60 lines (47 loc) · 2.14 KB
/
run_all.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
# Copyright 2015 Province of British Columbia
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
source("01_load.R")
source("02_clean.R")
source("03_analysis.R")
source("04_output.R")
source("05_databc_output.R")
mon_year <- format(Sys.Date(), "%B%Y")
outfile <- paste0("envreportbc_pm25_", mon_year, ".pdf")
rmarkdown::render("print_ver/pm25.Rmd", output_file = outfile)
# extrafont::embed_fonts(file.path("print_ver/", outfile))
## You will likely want to 'optimize pdf' in Acrobat to make the print version smaller
###############################################################################################
## copy files to web dev folder
air_indicators_path <- "~/soe_wwwd/indicators/air"
air_viz_path <- file.path(air_indicators_path, "pm25_viz/")
dir.create(air_viz_path, showWarnings = FALSE)
air_indicators_station_plots <- file.path(air_viz_path, "station_plots/")
dir.create(air_indicators_station_plots, showWarnings = FALSE)
web_viz_plots <- list.files("leaflet_map/station_plots", full.names = TRUE)
over_copy <- function(...) {
file.copy(..., overwrite = TRUE)
}
## Copy print version
over_copy(file.path("print_ver", outfile),
file.path(air_indicators_path, "print_ver/"))
## Copy the management viz map and bar chart plots
over_copy("out/pm_caaqs_mgmt_map.svg",
file.path(air_indicators_path, "images/"))
over_copy("out/pm_caaqs_mgmt_chart.svg",
file.path(air_indicators_path, "images/"))
## Copy leaflet map
over_copy("leaflet_map/leaflet_map.html", air_viz_path)
## Copy dataviz plots
lapply(list.files(air_indicators_station_plots, full.names = TRUE), file.remove)
lapply(web_viz_plots, over_copy, to = air_indicators_station_plots)