Suppose we have files in one folder file1.bin, file2.bin, ... , and file1460.bin in directory C:\R\Data 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 average and so on till 1460.in the end will get 360 files I tried to have them in a list,but did not know how to make the loop.
How do I read multiple files and manupulat them? in R language
I have been wasting countless hourse to figuer it out.any help
results <- array(dim=360)
for (i in 1:360){
results <- mean(yourlist[[(i*4):(i*4+3)]])
}
YMMV with the mean(yourList) call, but that structure would be how you could loop through the data once it's loaded.
for (i in 1:365){ results <- mean(listfile[[(i4):(i4+3)]]) writeBin(results) - hkfidd 2012-04-06 12:09
The basic idea is that you'll load all of the files into a list, then loop through and take the mean of every 4 using something like the loop above - Jeff Allen 2012-04-06 14:27