On 26/04/2010 7:07 AM, David.Epstein wrote:> In a .Rnw file I want to insert the R command
> pairs(mydataframe)
> and achieve the following effects
>
> 1. the command itseld is echoed into the tex document generated by Sweave
> <<fig=TRUE,echo=TRUE>>> 2. The graphics generated appears in
the tex document, with the graphics
> centred.
> 3. The R command > pairs(mydataframe) is not centered.
>
That is what I see when I do this:
\begin{center}
<<fig=TRUE, echo=TRUE>>mydataframe <- data.frame(a=1:10,
b=rnorm(10),
c=rnorm(10))
pairs(mydataframe)
@
\end{center}*
*Are you seeing the echoed source being centred?
Duncan Murdoch
> Sweave-manual.pdf gives the following code chunk
>
> <<results=tex,echo=FALSE>>=
> for(i in 1:4){
> file=paste("myfile", i, ".eps", sep="")
> postscript(file=file, paper="special", width=6, height=6)
> plot(rnorm(100)+i)
> dev.off()
> cat("\\includegraphics{", file, "}\n\n",
sep="")
> }
> @
>
> This could obviously be adapted to my centering problem, but is it the
> simplest way? It seems complicated compared with just pairs(mydataframe).
> Also, Sweave will normally make both postscript and pdf plots, but this
> would involve further complication in the code. I'm sure it's
completely
> standard to produce two copies of graphics, one a pdf and one an eps, but
> it's another obstacle in my way when I want to get on with writing the
> program and its latex description.
>
> Thanks
> David
>