Mercurial > repos > mingchen0919 > elastic_expose_data
comparison list_render.R @ 2:391394c022b8 draft
planemo upload commit dd293cd7bf2d71c81f268b67bac8add01ec6df0a-dirty
author | mingchen0919 |
---|---|
date | Sat, 31 Mar 2018 21:32:17 -0400 |
parents | |
children | 4f9f1e76f7e6 |
comparison
equal
deleted
inserted
replaced
1:16e0f4b7a286 | 2:391394c022b8 |
---|---|
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) | |
12 #------------------------------------------------ | |
13 | |
14 #------------------------------------------------ | |
15 options_and_arguments = read.table(paste0(Sys.getenv('REPORT_FILES_PATH'), '/options_and_arguments.txt'), | |
16 sep = '|', header = TRUE) | |
17 | |
18 #------------------------------------------------ | |
19 # create three folders within working directory | |
20 dir.create('list') | |
21 | |
22 #-----------------render Rmd-------------- | |
23 # copy R markdown file to working directory and render it within the working directory. | |
24 render(paste0(Sys.getenv('TOOL_INSTALL_DIR'), '/list.Rmd'), | |
25 output_file = paste0(Sys.getenv('REPORT_FILES_PATH'), '/report.html')) | |
26 | |
27 # for some unknow reason, directly using REPORT as the input value for output_file parameter | |
28 # in the render function can cause empty report file when the tool runs in batch mode. | |
29 # the solution is to render the rmarkdown to a explicitly specified file and then copy the | |
30 # file to ${REPORT} | |
31 system(command = 'cp ${REPORT_FILES_PATH}/report.html ${REPORT}') | |
32 system(command = 'sh ${REPORT_FILES_PATH}/script.sh') | |
33 #------------------------------------------ | |
34 | |
35 | |
36 ##--------end of code rendering .Rmd templates---------------- | |
37 sink() | |
38 ##=========== End of sinking output============================= |