[R] Sweave bug? when writing figures / deleting variable in chunk
Peter Dunn
dunn at usq.edu.au
Thu Jun 28 03:31:44 CEST 2007
> I have found a quite strange (to me) behaviour in Sweave. It only
> occurs in the following situation:
You need to understand what Sweave does when it creates pictures:
> <<>>=
> sel <- 1:5
> @
> <<fig=T>>=
> plot(trees[sel,])
> rm(sel)
> @
By default, a eps and pdf version of the graphic is made.
That is, this chunk producing the graphic is *run twice*:
once to make the eps file, once to make the pdf file.
After this code chunk is run once:
> <<fig=T>>=
> plot(trees[sel,])
> rm(sel)
...the variable sel is obviously deleted, so the
second time it runs... well, there's your error message.
Best to place the command rm( sel ) in it's
own separate chunk.
P.
--
Dr Peter Dunn | dunn <at> usq.edu.au
Faculty of Sciences, USQ; http://www.sci.usq.edu.au/staff/dunn
Aust. Centre for Sustainable Catchments: www.usq.edu.au/acsc
This email (including any attached files) is confidential an...{{dropped}}
More information about the R-help
mailing list