Mercurial > repos > mingchen0919 > rmarkdown_collection_builder
comparison collection_list_render.R @ 1:6be61cb4a1d5 draft
planemo upload for repository https://github.com/statonlab/docker-GRReport/tree/master/my_tools/rmarkdown_collection_builder commit 6df7b8ef3a603f7792ed5815ff324ede8a7b2b0b-dirty
author | mingchen0919 |
---|---|
date | Mon, 25 Sep 2017 16:19:52 -0400 |
parents | 78018b735124 |
children | 56b68a320c0e |
comparison
equal
deleted
inserted
replaced
0:78018b735124 | 1:6be61cb4a1d5 |
---|---|
30 # possible values: logical, integer, double, complex, character. | 30 # possible values: logical, integer, double, complex, character. |
31 ##------- 1. input data --------------------- | 31 ##------- 1. input data --------------------- |
32 spec_list=list() | 32 spec_list=list() |
33 spec_list$FILE_LIST = c('file_list', 'l', '1', 'character') | 33 spec_list$FILE_LIST = c('file_list', 'l', '1', 'character') |
34 spec_list$ECHO = c('echo', 'e', '1', 'character') | 34 spec_list$ECHO = c('echo', 'e', '1', 'character') |
35 spec_list$FORMAT = c('echo', 'f', '1', 'character') | |
35 ##--------2. output report and outputs -------------- | 36 ##--------2. output report and outputs -------------- |
36 spec_list$LIST_COLLECTION = c('list_collection', 'o', '1', 'character') | |
37 spec_list$REPORT = c('report', 'r', '1', 'character') | 37 spec_list$REPORT = c('report', 'r', '1', 'character') |
38 spec_list$OUTPUT_DIR = c('list_collection_dir', 'd', '1', 'character') | 38 spec_list$OUTPUT_DIR = c('list_collection_dir', 'd', '1', 'character') |
39 ##--------3. Rmd templates in the tool directory ---------- | 39 ##--------3. Rmd templates in the tool directory ---------- |
40 spec_list$LIST_COLLECTION_RMD = c('list_collection_rmd', 't', '1', 'character') | 40 spec_list$LIST_COLLECTION_RMD = c('list_collection_rmd', 't', '1', 'character') |
41 | 41 |
44 ##====== End of arguments handling ========== | 44 ##====== End of arguments handling ========== |
45 | 45 |
46 #------ Load libraries --------- | 46 #------ Load libraries --------- |
47 library(rmarkdown) | 47 library(rmarkdown) |
48 library(htmltools) | 48 library(htmltools) |
49 library(dplyr) | |
49 | 50 |
50 #----- 1. create the report directory ------------------------ | 51 #----- 1. create the report directory ------------------------ |
51 system(paste0('mkdir -p ', opt$list_collection_dir)) | 52 system(paste0('mkdir -p ', opt$list_collection_dir)) |
52 | 53 |
53 #----- 2. generate Rmd files with Rmd templates -------------- | 54 #----- 2. generate Rmd files with Rmd templates -------------- |
60 readLines(opt$list_collection_rmd) %>% | 61 readLines(opt$list_collection_rmd) %>% |
61 (function(x) { | 62 (function(x) { |
62 gsub('ECHO', opt$echo, x) | 63 gsub('ECHO', opt$echo, x) |
63 }) %>% | 64 }) %>% |
64 (function(x) { | 65 (function(x) { |
66 gsub('FORMAT', opt$echo, x) | |
67 }) %>% | |
68 (function(x) { | |
65 gsub('FILE_LIST', opt$file_list, x) | 69 gsub('FILE_LIST', opt$file_list, x) |
66 }) %>% | 70 }) %>% |
67 (function(x) { | 71 (function(x) { |
68 gsub('OUTPUT_DIR', opt$list_collection_dir, x) | 72 gsub('OUTPUT_DIR', opt$list_collection_dir, x) |
69 }) %>% | 73 }) %>% |
72 writeLines(x, con=fileConn) | 76 writeLines(x, con=fileConn) |
73 close(fileConn) | 77 close(fileConn) |
74 }) | 78 }) |
75 | 79 |
76 #------ 3. render all Rmd files -------- | 80 #------ 3. render all Rmd files -------- |
77 render('list_collection.Rmd', output_file = opt$list_collection_html) | 81 render('list_collection.Rmd', output_file = opt$report) |
78 | 82 |
79 #-------4. manipulate outputs ----------------------------- | 83 #-------4. manipulate outputs ----------------------------- |