0
|
1 ##============ Sink warnings and errors to a file ==============
|
|
2 ## use the sink() function to wrap all code within it.
|
|
3 ##==============================================================
|
|
4 zz = file(Sys.getenv('TOOL_LOG'))
|
|
5 sink(zz)
|
|
6 sink(zz, type = 'message')
|
|
7
|
|
8 #------------import libraries--------------------
|
|
9 options(stringsAsFactors = FALSE)
|
|
10
|
|
11 library(rmarkdown)
|
9
|
12 library(tidyverse)
|
0
|
13 #------------------------------------------------
|
|
14
|
|
15 #------------------------------------------------
|
9
|
16 arguments = read.table(paste0(Sys.getenv('REPORT_FILES_PATH'), '/arguments.txt'),
|
0
|
17 sep = '|', header = TRUE)
|
|
18
|
|
19
|
|
20 #-----------------render Rmd--------------
|
9
|
21 render(paste0(Sys.getenv('TOOL_INSTALL_DIR'), '/elastic_r_package.Rmd'),
|
0
|
22 output_file = paste0(Sys.getenv('REPORT_FILES_PATH'), '/report.html'))
|
|
23
|
|
24 # for some unknow reason, directly using REPORT as the input value for output_file parameter
|
|
25 # in the render function can cause empty report file when the tool runs in batch mode.
|
|
26 # the solution is to render the rmarkdown to a explicitly specified file and then copy the
|
|
27 # file to ${REPORT}
|
|
28 system(command = 'cp ${REPORT_FILES_PATH}/report.html ${REPORT}')
|
|
29 #------------------------------------------
|
|
30
|
|
31
|
|
32 ##--------end of code rendering .Rmd templates----------------
|
|
33 sink()
|
|
34 ##=========== End of sinking output============================= |