Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
411 views
in Technique[技术] by (71.8m points)

How do I read multiple binary files in R?

Suppose we have files in one folder file1.bin, file2.bin, ... , and file1460.bin in directory C:RData 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...