[R] Reading and treating multiple files....

From: Mayeul KAUFFMANN <mayeul.kauffmann_at_tiscali.fr>
Date: Wed 28 Jul 2004 - 07:10:58 EST

>I will get - in a few days- a set of separate files(one for each
records....~80'000 files pro year)
> named key.txt in which other info (measurements of pressure and velocity
at each second )
>is stocked; typically each one of this separate files will hold something
between 200 and
>1500 records....I'm supposed to do statistical analysis on this dataset,
on the yearly information
>Well, as you can suspect my problem is thus:
>- batch processing of these individual files :reading each file

I suggest you put all files in a single directory, then you use list.files () or dir()
to make a list of this files.
myfiles <- list.files ("c:\\mydir") #on windows Then you do a loop over these files with read.table() You can create a column named "file" with the name of the file.

All of this can be done with:

data <- NULL;for (i in dir("c:\\temp")) data <- rbind(data,cbind(file=i,read.table( paste("c:\\mydir\\",i,sep=""))))

Hope that helps

Univ. Pierre Mendes France
Grenoble - France

R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Jul 28 07:20:42 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:55:18 EST