Mercurial > repos > mingchen0919 > elastic_expose_data
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/list_render.R Sat Mar 31 21:32:17 2018 -0400 @@ -0,0 +1,38 @@ +##============ Sink warnings and errors to a file ============== +## use the sink() function to wrap all code within it. +##============================================================== +zz = file(Sys.getenv('TOOL_LOG')) +sink(zz) +sink(zz, type = 'message') + +#------------import libraries-------------------- +options(stringsAsFactors = FALSE) + +library(rmarkdown) +#------------------------------------------------ + +#------------------------------------------------ +options_and_arguments = read.table(paste0(Sys.getenv('REPORT_FILES_PATH'), '/options_and_arguments.txt'), + sep = '|', header = TRUE) + +#------------------------------------------------ +# create three folders within working directory +dir.create('list') + +#-----------------render Rmd-------------- +# copy R markdown file to working directory and render it within the working directory. +render(paste0(Sys.getenv('TOOL_INSTALL_DIR'), '/list.Rmd'), + output_file = paste0(Sys.getenv('REPORT_FILES_PATH'), '/report.html')) + +# for some unknow reason, directly using REPORT as the input value for output_file parameter +# in the render function can cause empty report file when the tool runs in batch mode. +# the solution is to render the rmarkdown to a explicitly specified file and then copy the +# file to ${REPORT} +system(command = 'cp ${REPORT_FILES_PATH}/report.html ${REPORT}') +system(command = 'sh ${REPORT_FILES_PATH}/script.sh') +#------------------------------------------ + + +##--------end of code rendering .Rmd templates---------------- +sink() +##=========== End of sinking output============================= \ No newline at end of file