[R] Sweave and graphs

Duncan Murdoch murdoch.duncan at gmail.com
Tue Sep 14 19:39:23 CEST 2010


  On 14/09/2010 1:18 PM, Katie Surrence wrote:
> I set my working directory to the location of the file (which I called
> Demo.Rnw) and I type Sweave("Demo.Rnw") at the R command line.
>
> Does that answer your question properly?

Yes, that looks fine.  So the problem is likely with pdflatex, or maybe 
you haven't really solved the Sweave.sty problem yet.
Do you run pdflatex locally, or do you try to run it from a different 
directory?  I doubt if that would work, because the path to the
images would be wrong.

Do you have a file called demo-FigureExample.pdf after running Sweave, 
and does pdflatex produce a demo.log file containing something like this:

<demo-FigureExample.pdf, id=1, 433.62pt x 433.62pt>
File: demo-FigureExample.pdf Graphic file (type pdf)

<use demo-FigureExample.pdf> [1

{C:/Users/murdoch/AppData/Local/MiKTeX/2.8/pdftex/config/pdftex.map}] [2 
<C:/te
mp/demo-FigureExample.pdf>]

or does it contain some errors?

Duncan Murdoch

> On Tue, Sep 14, 2010 at 12:08 PM, Duncan Murdoch
> <murdoch.duncan at gmail.com>wrote:
>
> >   On 14/09/2010 12:01 PM, Katie Surrence wrote:
> >
> >>  Hi all,
> >>
> >>  Having solved my Sweave.sty question, I'd like to figure out why my pdf
> >>  doesn't display the graph in my demo code.
> >>
> >>  Here's the demo code I'm using:
> >>
> >>  http://www.stat.berkeley.edu/~houston/demo.Rnw<http://www.stat.berkeley.edu/%7Ehouston/demo.Rnw>
> >>  <http://www.stat.berkeley.edu/%7Ehouston/demo.Rnw>
> >>
> >>
> >>  When I run Sweave within R (version 2.11) on the .Rnw it produces the
> >>  histogram in the graphics device in R.  When I then choose pdfLaTex in
> >>  Miktex (version 2.8) on the file demo.tex, the resulting pdf correctly
> >>  produces the table, but not the graph.
> >>
> >>  Here's the code from the .tex file that isn't working to generate the
> >>  graph:
> >>
> >>  \begin{figure}
> >>
> >>  \begin{center}
> >>
> >>  \includegraphics{demo-FigureExample}
> >>
> >>  \caption{This is my histogram for the the mean of 1000 samples of 10
> >>  N(0,1)
> >>  random
> >>
> >>  variables.}
> >>
> >>  \label{fig:hist}
> >>
> >>  \end{center}
> >>
> >>  \end{figure}
> >>
> >>
> >>
> >  It works for me, so I'd guess it's something in your pipeline.  How are you
> >  running Sweave?
> >
> >  Duncan Murdoch
> >
> >
>



More information about the R-help mailing list