-
-
Save nelsonauner/af155b771ae45105ef73 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# knit.sh -- Dave Kleinschmidt, April 2013 | |
# streamline knitting of Rnw files from the command line. | |
usage="Usage: $0 input-filename.Rnw [-nolatex] [-notangle]" | |
if [ $# -lt 1 ]; then | |
echo $usage | |
exit 1 | |
fi | |
rnwinput=$1 | |
shift | |
nolatex=0 | |
notangle=0 | |
while [ $# -gt 0 ] | |
do | |
case "$1" in | |
-nolatex) nolatex=1;; | |
-notangle) notangle=1;; | |
-*) echo $usage >&2 | |
exit 1;; | |
*) break;; | |
esac | |
shift | |
done | |
# first knit Rnw file into | |
fileName=${rnwinput%.*} | |
echo "library(knitr); knit(input='$rnwinput');" | R --no-save --no-restore | |
if [ $notangle -ne 1 ]; then | |
echo "library(knitr); knit(input='$rnwinput', tangle=T);" | R --no-save --no-restore | |
fi | |
if [ $nolatex -ne 1 ]; then | |
pdflatex ${fileName}.tex && pdflatex ${fileName}.tex | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment