[R] xyplots in lattice - strange behaviour, possible bug?

Manlio Calvi manlio.calvi at gmail.com
Wed Jan 22 23:10:52 CET 2014


Hello everyone,

I'm very green on R,  I'm following a Coursera course about it when I
hit a problem when I rewrote the same code the professor use in the
lecture.
I'm running Win 7 x64, R 3.0.2 x64 and the last version of Rstudio IDE

 I put up this script:


library(lattice)
x <- rnorm (100)
z <- x + rnorm(100)
f <- gl(2,50,labels =c("Groups 1" , "Groups 2"))
xyplot (z ~ x | f,
        panel = function (x, z, ...) {
          panel.xyplot(x,z, ...)
          panel.abline(h = median(z),
                       lty=2
                       )})


In my box don't work, it give no error in the terminal, the plotting
windonw will be opened, the graphbox drawed with all the ticks and the
titles as intended but instead of the actual data plot inside the
graph I have this error "Error using packet <x> argment "z" is
missing, with no default" where <x> is 1 or 2 as the script draw two
graphs.

I reported this behaviour in the lecture forum and someone replicated it.

I replicated this behaviour even with R alone running the above script
with the same results.

If I call traceback() no value is given, there is no traceback.

Apparently not everyone could replicate this behaviour for some reason.

As you could see the code must work but didn't.

A similar thing happens if I change the part after the function with
another like:

... <same code of above>...
 panel= function(x,y, ...) {
          panel.xyplot(x,z, ...)
          fit <- lm(y~x)
          panel.abline(fit)
        })

but don't happens if I call a xyplot without calling a function in it.

Have any ideas?



More information about the R-help mailing list