Re: [R] cygwin script for Sweave

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Fri 13 Oct 2006 - 18:39:59 GMT

On Windows you could just put this into sweave.bat, say, and then place that anywhere in your path (or in the current directory):

set infile=%~sdpn1
set infile=%infile:\=/%
cmd Rcmd Sweave %infile%.Rnw
pdflatex %infile%.tex
start %infile%.pdf

On 10/13/06, Thomas Harte <thomas.harte@yahoo.com> wrote:
> below is a very simple bash script to run Sweave from a cygwin terminal, run pdflatex on
> the generated .tex file, and then view the resulting .pdf output.
>
> i usually use cygwin when i am (forced to be on) Windoze, but i found a few issues
> with paths that this script works around.
>
> pdfview, used in the script, is simply:
>
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> $ cat /usr/local/bin/pdfview
> #!/bin/bash.exe
>
> if [ $# -eq 1 ]
> then
> /c/Program\ Files/Adobe/Acrobat\ 6.0/Reader/AcroRd32.exe `cygpath -w -a -s "$1"`
> else
> /c/Program\ Files/Adobe/Acrobat\ 6.0/Reader/AcroRd32.exe
> fi
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>
> mutatis mutandis for your own Adobe Reader.
>
>
> here is the script:
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> #!/bin/bash.exe
> # rnw.sh [.Rnw file]
> #
> # $1 must be a .Rnw file
> #
> RNWFILE=$1
> PWD=`pwd`
> FILEBASE=`basename $1 .Rnw`
> TEXFILE=$FILEBASE.tex
> PDFFILE=$FILEBASE.pdf
>
> echo " \
> library(\"utils\"); \
> setwd(\"`cygpath -m $PWD`\"); \
> Sweave(\"$RNWFILE\") \
> " \
> | /c/R/R-2.3.1/bin/Rterm.exe --no-save --no-restore
>
> # the resulting .tex file contains an annoying "c:" ...
> # replace it with the pdflatex-friendly "/c" :
> sed -e 's/c:/\/c/g' --in-place $TEXFILE
>
> # now run text processing
> pdflatex $TEXFILE
> pdfview $PDFFILE &
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat Oct 14 05:43:46 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 13 Oct 2006 - 21:30:10 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.