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

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -