Skip to content
Prev 174944 / 398503 Next

How to: Read Multi-filtes and sort to different files

Dear Mr. Li,

To make things simpler, you could place the files corresponding to
different stations in different directories. Then:

1) I would loop over the directories.

2) I would use dir and loop through the resulting vector (that would
contain the file names).

3) I would use read.table with parameters skip (to skip the header) and
the header option set to true.

4) I would aggregate the resulting files in a single big file.

There are ways to do that. Some involve using for loops; you can also
use sapply to loop over files and cbind if you feel confident with a
command similar to

do.call( cbind, sapply( dir(), read.table, skip = 1, header = TRUE ) )

I have not been able to test the expression above and it may not even
parse in R but it is close to something that should work.

Best regards,

Carlos J. Gil Bellosta
http://www.datanalytics.com
On Wed, 2009-03-25 at 14:30 -0700, Qianfeng Li wrote: