From c8ddd083e27ee32f89e77d6032ebd580d0ed9cf4 Mon Sep 17 00:00:00 2001
From: Holger Brandl <brandl@mpi-cbg.de>
Date: Fri, 12 Sep 2014 17:50:30 +0200
Subject: [PATCH] cont. new groups analysis

---
 R/rknit/rknit.sh | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/R/rknit/rknit.sh b/R/rknit/rknit.sh
index 470891a..5f2fda0 100644
--- a/R/rknit/rknit.sh
+++ b/R/rknit/rknit.sh
@@ -10,10 +10,10 @@ rknit(){
     ## rscript=/Users/brandl/Dropbox/Public/datautils/R/rknit/rknit_example.R
     rscript=$1
 
-#    tmdRmd=$(mktemp  --suff .Rmd)
-    tmdRmd=$(basename $rscript .R).Rmd
+#    tmpRmd=$(mktemp  --suff .Rmd)
+    tmpRmd=$(basename $rscript .R).Rmd
 
-#    echo '# '$(basename $rscript .R) > $tmdRmd
+#    echo '# '$(basename $rscript .R) > $tmpRmd
 
     ## alternatively we could use the header argument for knit2html
     echo '
@@ -23,15 +23,20 @@ rknit(){
     }
 </style>
 ```{r}
-    ' > $tmdRmd
+    ' > $tmpRmd
 
-#    cat $rscript | grep -Fv '#!' | Rscript --vanilla  - 'require(stringr); require(dplyr); readLines(file("stdin")) %>% str_replace("^#([#]*)> ([^{]*)([{]+.+[}])?", "```\n\\1 \\2\n```{r \\3}") %>% collapsewriteLines(stdout())' # >> $tmdRmd
-#    cat $rscript | grep -Fv '#!' | Rscript --vanilla -e 'source("/Users/brandl/Dropbox/Public/datautils/R/rknit/rknit_preprocessor.R")'  >> $tmdRmd
-#    cat $rscript | sed 's/^#>$//g'| grep -Fv '#!' | Rscript --vanilla -e 'devtools::source_url("https://raw.githubusercontent.com/holgerbrandl/datautils/master/R/rknit/rknit_preprocessor.R")' | grep -v "^#>" >> $tmdRmd
-    cat $rscript | sed 's/^#>$//g'| grep -Fv '#!' | Rscript --vanilla -e 'devtools::source_url("https://dl.dropboxusercontent.com/u/113630701/datautils/R/rknit/rknit_preprocessor.R")' | grep -v "^#>" >> $tmdRmd
+#    cat $rscript | grep -Fv '#!' | Rscript --vanilla  - 'require(stringr); require(dplyr); readLines(file("stdin")) %>% str_replace("^#([#]*)> ([^{]*)([{]+.+[}])?", "```\n\\1 \\2\n```{r \\3}") %>% collapsewriteLines(stdout())' # >> $tmpRmd
+#    cat $rscript | grep -Fv '#!' | Rscript --vanilla -e 'source("/Users/brandl/Dropbox/Public/datautils/R/rknit/rknit_preprocessor.R")'  >> $tmpRmd
+#    cat $rscript | sed 's/^#>$//g'| grep -Fv '#!' | Rscript --vanilla -e 'devtools::source_url("https://raw.githubusercontent.com/holgerbrandl/datautils/master/R/rknit/rknit_preprocessor.R")' | grep -v "^#>" >> $tmpRmd
+    cat $rscript | sed 's/^#>$//g' | grep -Fv '#!'| grep -v '^#*$' | Rscript --vanilla -e 'devtools::source_url("https://dl.dropboxusercontent.com/u/113630701/datautils/R/rknit/rknit_preprocessor.R")' | grep -v "^#>" >> $tmpRmd
 
-    echo '```' >> $tmdRmd
+    echo '```' >> $tmpRmd
 
-    echo 'require(knitr); options(width=150); opts_chunk$set(cache = TRUE, fig.width=10, width=100); knit2html("'$tmdRmd'", output="'$(basename $rscript .R)'")' | R --vanilla -q
+    echo 'require(knitr); options(width=150); opts_chunk$set(cache = TRUE, fig.width=10, width=100); knit2html("'$tmpRmd'", output="'$(basename $rscript .R)'")' | R --vanilla -q
+
+    rm $(basename $rscript .R) $tmpRmd
 }
 
+
+## notes
+# http://yihui.name/knitr/options --> strip.white:
-- 
GitLab