forked from ices-taf/SmartDotsReport_template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreport.R
More file actions
64 lines (51 loc) · 1.51 KB
/
Copy pathreport.R
File metadata and controls
64 lines (51 loc) · 1.51 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
## Prepare plots/tables for report
## Before:
## After:
# load libraries
library(icesTAF)
library(rmarkdown)
library(jsonlite)
library(knitr)
library(pander)
library(ggplot2)
library(scales)
library(dplyr)
# make report directory
mkdir("report")
# source utilities
source("utilities_report.R")
# load configuration data
config <- read_json("config.json", simplifyVector = TRUE)
# load data for report
dist <- read.taf("data/dist.csv")
ad_long_all <- read.taf("data/ad_long.csv")
ad_long_ex <- read.taf("data/ad_long_ex.csv")
# get csv files
for (file in dir("model", pattern = "*.csv")) {
assign(gsub(".csv", "", file),
read.taf(paste0("model/", file))
)
}
# now rdata files
for (file in dir("model", pattern = "*.rds")) {
assign(tools::file_path_sans_ext(file),
readRDS(paste0("model/", file))
)
}
# render summary and copy to report folder
summary_filename <- paste0(config$summary_name, ".docx")
render("report_summary.Rmd",
params = list(summary_title = config$summary_title,
strata = config$strata),
output_file = summary_filename,
encoding = "UTF-8")
cp(summary_filename, "report", move = TRUE)
# render report and copy to report folder
report_filename <- paste0(config$report_name, ".docx")
render("report_full.Rmd",
params = list(report_title = config$report_title,
strata = config$strata),
output_file = report_filename,
encoding = "UTF-8")
cp(report_filename, "report", move = TRUE)
# finally copy to sharepoint?