Kevin Ushey
Kevin Ushey

Reputation: 21285

How can I include smoothed lines in lattice splom call?

Consider the following code:

library(lattice)
m <- matrix(1:16, nrow=4)
splom(m, panel=function(x, y, ...) {
  panel.xyplot(x, y, ...)
  panel.smooth(x, y, ...) ## this line doesn't seem to work
})

Calling this gives me the error:

Error in grid.Call.graphics(L_downviewport, name$name, strict) : 
  Viewport 'plot_01.panel.1.1.off.vp' was not found

What am I doing wrong? Is this a bug? How can I superpose smoothed lines in a lattice splom?

> sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=C                 LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] lattice_0.20-23

loaded via a namespace (and not attached):
[1] grid_3.0.1

Upvotes: 2

Views: 1039

Answers (1)

Kevin Ushey
Kevin Ushey

Reputation: 21285

panel.smooth is, in fact, a function from graphics rather than lattice; the name is unfortunately misleading (I thought it was part of the family of lattice panel functions, but I was wrong).

panel.loess is probably preferred.

Upvotes: 1

Related Questions