[R] write to M, using row and columns taken from A and B, with values from C

Amen amen.alyaari at Bordeaux.inra.fr
Fri Apr 27 08:22:11 CEST 2012


Thanks a lot for your reply.
I have managed to do it but still something that I do not know how to do
that.This code below will read the first row in D and write it to a new
file.I want to make a another loop to read all rows and write each result of
every row to a file.

library(Matrix)
 M <- Matrix(-9999, 360, 720)## creat matrix with 720 columns and 360 rows
ith valus of -9999
 tm<-t(M)
 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)
 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)
 wind <- file("C:\\Users\\aalyaari\\Desktop\\Wind_WFD_200201.bin", "rb")
 C=readBin(wind, double(), size=4,n=67420*248, signed=TRUE)
 D<-matrix(C,nrow=248,ncol=67420)
 for(i in 1:67420){tm[ta[i],tb[i]]=D[1,i]}
  to.write =
file(paste("C:\\Users\\aalyaari\\Desktop\\Yar15.bin",sep=""),"wb")
 writeBin(as.real(tm), size=4,to.write)

--
View this message in context: http://r.789695.n4.nabble.com/write-to-M-using-row-and-columns-taken-from-A-and-B-with-values-from-C-tp4589197p4591852.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list