[R] Problems converting output from Sweave to PDf
Dirk Eddelbuettel
edd at debian.org
Fri Dec 26 16:53:35 CET 2003
On Fri, Dec 26, 2003 at 12:59:42PM +0100, Uwe Ligges wrote:
> Thon de Boer wrote:
> > I am having trouble converting the output from Sweave
> > into a valid PDF file.
> >
> > I have created a simple .Rnw file which will become a
> > full vignette at some point, but during the
> > intermediate testing, I got errors from texi2dvi.
> > This is what I have done.
> >
> > 0) Using a Windows Xp system
> > 1) Created a file called GeneSpring.Rnw
> > 2) Convert this to Tex using Sweave("GeneSpring.Rnw")
> > from within R
> > 3) Since I don't have LATEX for windows, I used
> > texi2dvi from the CYGWIN package
> > 4) When I run the command in Cygwin 'texi2dvi -c -p
> > GeneSpring.tex' I get the error shown below.
> > 5) When I edit the GeneSpring.tex file and comment out
> > the line
> >
> > \usepackage{C:/PROGRA~1/SILICO~1/GENESP~1/data/rw1081/share/texmf/Sweave}
>
> Well, cygwin misinterprets the path. Specify it in a way cygwin
> understands, e.g.:
> /cygdrive/c/.....
> or even better, install a LaTeX environment for Windows.
Why? Cygwin and Sweave get along very well. Here is a little utility script
I use:
nbkh85c at minot:~> cat bin/sweave
#!/bin/bash -e
function errorexit () {
echo "Error: $1"
exit 1
}
function filetest () {
if [ ! -f $1 ]; then
errorexit "File $1 not found"
fi
return 0
}
if [ "$#" -lt 1 ]; then
errorexit "Need to specify argument file"
fi
BASENAME=$(basename $1 .Rnw)
RNWFILE=$BASENAME.Rnw
filetest $RNWFILE
echo "library(tools); Sweave(\"$RNWFILE\")" \
| Rterm --no-save --no-restore --slave
LATEXFILE=$BASENAME.tex
filetest $LATEXFILE && pdflatex $LATEXFILE
PDFFILE=$BASENAME.pdf
filetest $PDFFILE && acroread `pwd`/$PDFFILE &
Note that it needs another three line script acroread which uses cygpath to
translate the path to the actual pdf file so that the windows binary can
grok it.
Hth, Dirk
--
Those are my principles, and if you don't like them... well, I have others.
-- Groucho Marx
More information about the R-help
mailing list