[R] possible bug in image() ??

Gareth Davies gd340 at uow.edu.au
Mon Oct 10 04:26:47 CEST 2005


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




More information about the R-help mailing list