-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreport.R
67 lines (56 loc) · 1.71 KB
/
report.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
## Prepare plots/tables for report
## Before:
## After:
# # load libraries
library(icesTAF)
library(rmarkdown)
library(jsonlite)
library(knitr)
#
library(pander)
library(ggplot2)
library(scales)
unloadNamespace("plyr")
library(dplyr)
library(Hmisc)
# make report directory
mkdir("report")
# source utilities
source("utilities.R")
source("utilities_report.R")
# load configuration data
#config <- read_json("bootstrap/data/config.json", simplifyVector = TRUE)
config <- read_json("bootstrap/initial/data/config.json", simplifyVector = TRUE)
# load data for report
ad_long_all <- read.taf("data/ad_long.csv")
ad_long_adv <- read.taf("data/ad_long_adv.csv")
# # set strata to NULL is all are NA
# if (all(is.na(ad_long_all[[config$strata]]))) config$strata <- NULL
# 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)