Suppose we have files in one folder file1.bin, file2.bin, ... , and
1460slice(file) with dim of 720 * 360 in directory C:\\PHD\\Climate
Data\\Wind\\   and we want to read them and make a loop to go from 1 to 4
and take the average,  then from 4 to 8 and so on till 1460. in the end we
will get 365 files . I need those 365 files to be in one  new folder for
later use in my model
I tried using this code but didnt seem to be right :
Testarray<-array(0, dim=c(1460,720,360))
listfile<-dir("C:\\PHD\\Climate Data\\Wind\\")
for (i in c(1:1460)) {
     Testarray <- file(listfile[i], "rb")
      Testarray[i,,]<- readBin(conne, integer(), size=2,  n=360*720,
signed=F)
             results <- mean(listfile[[(i*4):(i*4+3)]])
              results1<-    writeBin(results)
close(conne)
}
Thanks in advance




--
View this message in context: 
http://r.789695.n4.nabble.com/read-multiaple-files-within-one-folder-tp4537394p4537394.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to