# [R] possible bug in image() ??

From: Gareth Davies <gd340_at_uow.edu.au>
Date: Mon 10 Oct 2005 - 12:26:47 EST

Hi everyone.
The function image() seems not to be correctly plotting some matrices that I give it. (I’m using R 2.1.1) The following code creates a matrix (denoted x) with 1500 rows and 3 columns, with all entries 0 or 1, and then plots the image of this matrix.

cc=runif(n=1500,min=0.1,max=1.2)
ccc=ceiling(cc-1)
dd=runif(n=1500,min=0.1,max=1.2)
ddd=ceiling(dd-1)
ee=runif(n=1500,min=0.1,max=1.2)
eee=ceiling(ee-1)
x=matrix(data=c(ccc,ddd,eee),nrow=1500)  image(x)

..where the first column in x (vector ccc) is depicted horizontally along the bottom of the image. However, when I overplot the non-zero elements of the vectors ccc, ddd and eee onto their respective horizontal positions on the image,..

``` points(seq(0,1,1/(1500-1)),(ccc)^-1*0)
points(seq(0,1,1/(1500-1)),(ddd)^-1*0.5)
points(seq(0,1,1/(1500-1)),(eee)^-1*1)

```

…the locations of the 1’s in image do not always match the locations of the 1’s in ccc,ddd, and eee (although they are mostly correct). Do other people find this problem?? I've tried with other matrices, and the results only seem in error when the matrix is large, say with more than 1000 rows.

Cheers, Gareth Davies

R-help@stat.math.ethz.ch mailing list