[R] Sweave question

Duncan Murdoch murdoch.duncan at gmail.com
Thu Apr 29 13:12:58 CEST 2010


On 28/04/2010 11:31 PM, Felipe Carrillo wrote:
> Hi:
> I am using Sweave and texi2dvi to generate a LaTeX document but
> can't find the way to hide the graphics while the R chunks are being
> executed. I thought results=hide would do it but that't not the case. 
>   

Sweave runs figure chunks multiple times.  The first time is probably 
what you're seeing:  it just runs the code, with no special devices 
created.  You need to tell R to use something other than your screen as 
the default device for this.  That's what happens if you run Sweave in 
batch mode, or if you choose options(device="pdf").  (You'll get a file 
Rplots.pdf created.)

Duncan Murdoch
> If I do:
> \begin{figure}[h]
> <<figA=true,echo=F,fig=T,results=hide>>=
> a < rnorm(1000)
> plot(a)
> @
> \caption{Weekly estimates.}
> \label{figure:ggplot1}
> \end{figure}
>
> The graphic doesn't get displayed but gets printed on the document
>
> but the code below shows the graphic.......how can I hide it??
> \begin{figure}[h]
> <<figA=true,echo=F,fig=T,results=hide>>=
> library(ggplot2)
> winter <- read.csv("Winter_AllYears.csv")
> wintermelt <- melt(winter,id="week")
> print(ggplot(wintermelt,aes(week,value/1000)) + geom_line(aes(colour=variable))+ opts(legend.position="none") +
> facet_wrap(~variable,ncol=2) + opts(title="Winter") + labs(y="Number of fish X 1,000",x="WEEK"))
> @
> \caption{Weekly estimates.}
> \label{figure:ggplot1}
> \end{figure}
>  
> Felipe D. Carrillo
> Supervisory Fishery Biologist
> Department of the Interior
> US Fish & Wildlife Service
> California, USA
>
>  
> Felipe D. Carrillo
> Supervisory Fishery Biologist
> Department of the Interior
> US Fish & Wildlife Service
> California, USA
>
>
>
>
> ______________________________________________
> R-help at r-project.org 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.
>



More information about the R-help mailing list