[R] Sweave: infelicities with lattice graphics

Michael Friendly friendly at yorku.ca
Sun Sep 12 20:39:29 CEST 2010

Thanks Deepayan and Duncan.  The eval=FALSE was the problem, rather than 
anything with
lattice. Not sure why that worked earlier, but I no longer care.

Deepayan Sarkar wrote:
> On Sun, Sep 12, 2010 at 8:47 AM, Duncan Murdoch
> <murdoch.duncan at gmail.com> wrote:
>> On 12/09/2010 11:41 AM, Michael Friendly wrote:
>>> Just a follow-up on this thread, now with R 2.11.1.  I was happy back then
>>> to use Deepayan's solution for this, under earlier R versions; but it now
>>> gives an error and the Sweave-generated .tex file no longer compiles.
>>> <<ortho-xyplot1-code, keep.source=TRUE, eval=FALSE>>=
>>> library(nlme)
>>> library(lattice)
>>> xyplot(distance ~ age|Sex, data=Orthodont, type='b', groups=Subject,
>>> pch=15:25,
>>>     col=palette(), cex=1.3, main="Orthodont data")
>>> @
>>> <<ortho-xyplot1,fig=TRUE, include=FALSE, echo=FALSE, width=6, height=6>>=
>>> plot(trellis.last.object())
>>> @
>>> Now, I get the following from Sweave:
>>> Error:  chunk 46 (label=ortho-xyplot1)
>>> Error in !lattice.getStatus("current.plot.saved", prefix = prefix) :
>>>   invalid argument type
>>> Did something in lattice change so that plot(trellis.last.object()) no
>>> longer works or needs to be specified differently?
>> I don't know if something in lattice has changed, but that doesn't look as
>> though it should work:  the code to do the plot was never evaluated.  I
>> think you would need eval=TRUE in the first chunk, or
>> <<ortho-xyplot1-code>>
>> ahead of the plot command in the second.
> Yes. I notice that it was me who introduced the eval=FALSE (I'm not
> sure why). Hopefully that should fix it.
> However, there _has_ been a recent lattice update, where the internals
> have undergone some change, so there is a chance that is to blame. I
> won't be able to take a look before day after tomorrow.
> -Deepayan

Michael Friendly     Email: friendly at yorku.ca 
Professor, Psychology Dept.
York University      Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Street    http://datavis.ca
Toronto, ONT  M3J 1P3 CANADA

More information about the R-help mailing list