[R] Min , Max

Jonsson amen.alyaari at Bordeaux.inra.fr
Mon Apr 30 16:01:19 CEST 2012


Hi again,
Sorry for connecting you again(I am still getting this error:subscripts out
of bounds). the problem is that I am trying to apply R script for one file
to many files. It succeeded to do that for the first file but not for the
others.I think the problem in my code is that  ( d )  (in the two last
lines)is not correct. I think I shall write another loop for writing the
results but didn't know how to do that.   Merci d'avance 

library(Matrix)
listfile<- list.files("C:\\Users\\aalyaari\\Desktop\\New folder 7", "*.bin",
full.names = TRUE)
long <- file("C:\\Users\\aalyaari\\Desktop\\New folder (5)\\inra.bin", "rb")
 A=readBin(long, integer(), size=2,n=67420*1, signed=F)
 ta<-t(A)
close(long)
 lot <- file("C:\\Users\\aalyaari\\Desktop\\New folder (5)\\lat.img", "rb")
 B=readBin(lot, integer(), size=2,n=67420*1, signed=F)
 tb<-t(B)
close(lot)
for(h in length(listfile))
{b=file.info(listfile[h])$size/67420/4
 wind <- file(listfile[h]), "rb")
C=readBin(wind, double(), size=4 ,n=b*67420, signed=TRUE)
close(wind)
D<-matrix(C,nrow=b,ncol=67420)
for(d in 1:b)
 {M <- Matrix(-9999, 360, 720)
 tm<-t(M)
for(i in 1:67420)
{tm[ta[i],tb[i]]= round(10 * mean(D[(d-1)*8 + 1:8), i])
    
          }
          to.write <- sprintf("C:\\Users\\aalyaari\\Desktop\\New folder
(6)\\Yar_%00d.bin", d)
          writeBin(as.integer(tm at x), size=2,to.write)
  }
}


--
View this message in context: http://r.789695.n4.nabble.com/Min-Max-tp4593065p4598289.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list