[R] Sweave and Trellis in R 2.0.0patched (Windows)

Deepayan Sarkar deepayan at stat.wisc.edu
Tue Oct 19 22:28:56 CEST 2004


On Tuesday 19 October 2004 13:49, you wrote:

[...]

>
> I've included the following files:
> Plt.dat - This is the xyplot using save()
> Full.data - This is the entire environment using save.image()

Thanks. Turns out this was a bug in trellis.par.set (a missing 
assignment), and can be reproduced (in a fresh R session) by 

> library(lattice)
> x11()  ## or any other device
> trellis.par.set(theme = col.whitebg())
> xyplot(1 ~ 1)
Error in "[<-"(`*tmp*`, pos.heights[[nm]], value = numeric(0)) : 
 nothing to replace with

The issue was that a call to trellis.device() needs to be made somewhere 
along the way so that the proper settings are initialized (which would 
then be overwritten by 'theme'). trellis.par.set was detecting if it 
needed to do this, but wasn't handling the situation correctly, leading 
to inconsistent settings.

This should be fixed in the next release of lattice. For now, a 
workaround (which is functionally equivalent to what you are doing now) 
is to replace 

trellis.par.set(theme = col.whitebg())

by 

lattice.options(default.theme = "col.whitebg")

Deepayan


[...]

> On Tuesday 19 October 2004 12:43, Shawn Way wrote:
> >  I've been using the following code to plot using Sweave in version
> > 1.9.1
> >
> > library(RODBC)
> > library(lattice)
> > channel <-odbcConnectExcel("h:/water.xls")
> > data <- sqlQuery(channel,"select * from `Sheet1$` where Test =
> > 'TOC' and (Valve='5010-05' or Valve='8030-V26' or Valve='1180-08'
> > or Valve='5040-08')")
> > odbcClose(channel)
> > srt <- order(as.POSIXct(data$'DateTime Sampled')) data <-
> > data[srt,] data <- data[!is.na(data$Value),]
> > start1 <- strptime(c("6/1/2003"),format="%m/%d/%Y")
> > end1 <- strptime(c("5/1/2004"),format="%m/%d/%Y")
> > data.plot <- data[
> >                   data$'DateTime Sampled'>= start1
> > #                  & is.na(data$Exclude)
> >                   & data$'DateTime Sampled' <= end1
> >                   ,]
> > trellis.par.set(theme=col.whitebg())
> > print(xyplot(data.plot$Value~data.plot$'DateTime
> > Sampled'|data.plot$Valve,
> >            data=data.plot,
> >            panel= function(x,y) {
> >                       panel.xyplot(x,y,type="b")
> >                       panel.abline(h=500,col="red")
> >                     },
> >            layout=c(1,4),
> >            type="b",
> >            main="TOC Values for Various Systems",
> >            xlab="Date",
> >            ylab="TOC (ppb)"
> >           ))
> >
> > But under version 2.0.0 it gives the following error:
> > > Sweave("M:\\Engineering\\Shawn\\BMF\\MECO\\Clean
> > > Steam\\32-04.rnw")
> >
> > Writing to file 32-04.tex
> > Processing code chunks ...
> >  1 : term hide eps pdf
> > Error in "[<-"(`*tmp*`, pos.heights[[nm]], value = numeric(0)) :
> >  nothing to replace with
> > Error in driver$runcode(drobj, chunk, chunkopts) :
> >  Error in "[<-"(`*tmp*`, pos.heights[[nm]], value = numeric(0)) :
> >
> >  nothing to replace with




More information about the R-help mailing list