Reputation: 751
I know the following would work in a terminal in linux to knit Rnw file into pdf, but there are simply too many lines while for Rstudio doing this only requires one click. Could someone provide a linux shell function to handle the filename as a variable? I tryied with $1 for example, but there are "" and '' for Rscript and Rnw file name, and the shell could not recognize what is $1.
Rscript -e "library(knitr); knit('my_sweave_file.Rnw')"
pdflatex my_sweave_file.tex
Upvotes: 0
Views: 153
Reputation: 6151
You could use something like this. Save as a file and make sure it is runnable (i.e., use chmod +x nameofscript
).
#!/bin/bash
# Set the first argument as variable file
file=$1
filename=$(basename "$file")
extension="${filename##*.}"
filename="${filename%.*}"
Rscript -e "library(knitr); knit('$file')" ; pdflatex $filename.tex
Upvotes: 1