comparison bdss_client_render.R @ 20:531c00a2acbf draft

planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_bdss_client commit b3bd3152ad843fa878cb043b8abb88397ddbba4e-dirty
author mingchen0919
date Sat, 14 Oct 2017 17:15:39 -0400
parents 246cb7315673
children
comparison
equal deleted inserted replaced
19:14a50f9cca69 20:531c00a2acbf
1 library(getopt)
2 library(rmarkdown)
3 library(htmltools)
4 library(dplyr)
5 library(RCurl)
6
7
1 ##============ Sink warnings and errors to a file ============== 8 ##============ Sink warnings and errors to a file ==============
2 ## use the sink() function to wrap all code within it. 9 ## use the sink() function to wrap all code within it.
3 ##============================================================== 10 ##==============================================================
4 zz = file('warnings_and_errors.txt') 11 zz = file('warnings_and_errors.txt')
5 sink(zz) 12 sink(zz)
35 ##--------3. Rmd templates in the tool directory ---------- 42 ##--------3. Rmd templates in the tool directory ----------
36 args_list$BDSS_CLIENT_RMD = c('bdss_client_rmd', 't', '1', 'character') 43 args_list$BDSS_CLIENT_RMD = c('bdss_client_rmd', 't', '1', 'character')
37 44
38 opt = getopt(t(as.data.frame(args_list))) 45 opt = getopt(t(as.data.frame(args_list)))
39 46
40 ##=============STEP 2: loading libraries=====================
41 ##
42 ##===========================================================
43 library(rmarkdown)
44 library(htmltools)
45 library(dplyr)
46 library(RCurl)
47 47
48 ##=======STEP 3: create report directory (optional)========== 48 ##=======STEP 2: create report directory (optional)==========
49 ## 49 ##
50 ##=========================================================== 50 ##===========================================================
51 dir.create(opt$report_dir) 51 dir.create(opt$report_dir)
52 52
53 ##=STEP 4: replace placeholders in .Rmd with argument values= 53 ##=STEP 3: replace placeholders in .Rmd with argument values=
54 ## 54 ##
55 ##=========================================================== 55 ##===========================================================
56 #++ need to replace placeholders with args values one by one+ 56 #++ need to replace placeholders with args values one by one+
57 #----- 01 bdss_client.Rmd ----------------------- 57 #----- 01 bdss_client.Rmd -----------------------
58 readLines(opt$bdss_client_rmd) %>% 58 readLines(opt$bdss_client_rmd) %>%
69 fileConn = file('bdss_client.Rmd') 69 fileConn = file('bdss_client.Rmd')
70 writeLines(x, con=fileConn) 70 writeLines(x, con=fileConn)
71 close(fileConn) 71 close(fileConn)
72 }) 72 })
73 73
74 ##=============STEP 5: render .Rmd templates================= 74 ##=============STEP 4: render .Rmd templates=================
75 ## 75 ##
76 ##=========================================================== 76 ##===========================================================
77 render('bdss_client.Rmd', output_file = opt$report_html) 77 render('bdss_client.Rmd', output_file = opt$report_html)
78 78
79 79