[R-sig-Geo] Image funct doesn't plot final matrix (after RandomFields' GaussRF)

Ruben Roa RRoa at fisheries.gov.fk
Wed May 11 17:43:37 CEST 2005


Hi people:
I wrote the code below to create N.sim random fields with RandomFields' 
GaussRF, in which a proportion of rows and columns (given by prow and 
pcol) are replaced by rows and columns of zeroes.
My problem is that with any simulation output when i use
image(x,y,mcola) instead of a plot with some random bands and columns of zeros 
i get a plot of the matrix as it comes out of GaussRF, full with positive realizations.
When i check the files written on the disk though (called mcolasim3.1, etc)
they do have the bands and columns of zeros i intended them to have.
Why is not image using the latest matrix (after the two final for-loops) instead
of the matrix coming untouched from GaussRF?
Thanks in advance,
Ruben

###########
function(N.sim,pcol,prow){
x<-seq(1,180,1)
y<-seq(1,540,1)
param<-c(6.63,2.24,1.82,4.36)
names(param)<-c("beta","sigmasq","tausq","varphi")
for(i in 1:N.sim){
                       mcola<-GaussRF(x=x,y=y,param=param,grid=TRUE,model="gauss")
                       for(j in 1:540){
                                          if(runif(1)<prow) mcola[,j]<-mcola[,j] else mcola[,j]<-mat.or.vec(180,1)
                                          }
                       for(k in 1:180){
                                          if(runif(1)<pcol) mcola[k,]<-mcola[k,] else mcola[k,]<-t(mat.or.vec(540,1))
                                          }
                                          file.out<-paste("mcolasim3",i,sep=".")
                                          write(t(mcola),file.out,ncol=ncol(t(mcola)))
                                          }
                       }
#############




More information about the R-sig-Geo mailing list