r - knitr in command line in linux -
i know following work in terminal in linux knit rnw file pdf, there many lines while rstudio doing requires 1 click. provide linux shell function handle filename variable? tryied $1 example, there "" , '' rscript , rnw file name, , shell not recognize $1.
rscript -e "library(knitr); knit('my_sweave_file.rnw')" pdflatex my_sweave_file.tex
you use this. save file , make sure runnable (i.e., use chmod +x nameofscript
).
#!/bin/bash # set first argument variable file file=$1 filename=$(basename "$file") extension="${filename##*.}" filename="${filename%.*}" rscript -e "library(knitr); knit('$file')" ; pdflatex $filename.tex
Comments
Post a Comment