[R] image of expand.grid

Uwe Ligges ligges at statistik.uni-dortmund.de
Sun May 4 16:31:37 CEST 2003


juli g. pausas wrote:
> Hi all,
> It is not clear to me why this cannot be ploted with image. Any help?
> 
>  > g <- data.frame(expand.grid(x= 1:5, y= 1:5), z= rnorm(25))
>  > image(g)
> Error in image.default(g) : increasing x and y values expected
>  > is.list(g)
> [1] TRUE
>  > g$x
> [1] 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5
>  > g$y
> [1] 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 5 5 5 5 5
>  >
> 

The error message states: "increasing x and y values expected".
image() is really clever and you don't need expand.grid() in this case 
(in principle, image() does it itself):

  g <- list(x = 1:5, y = 1:5, z = matrix(rnorm(25), 5))
  image(g)

Uwe Ligges

> Thanks in advance
> 
> Juli
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help



More information about the R-help mailing list