[R] Automatic File Reading

Jerome Asselin jerome.asselin at crchum.qc.ca
Wed Oct 18 17:24:48 CEST 2006


On Wed, 2006-10-18 at 17:09 +0200, Lorenzo Isella wrote:
> Dear All,
> I am given a set of files names as:
> velocity1.txt
> velocity2.txt
>  and so on.
> I am sure there must be a way to read them automatically in R.
> It is really taking me longer to read them than to analyze them.
> Anybody has a suggestion to help me out with this?
> Many thanks

Not what you mean by "reading".
?read.table
?read.csv
?scan
...

However, consider this example. If you have 100 files, you can do:

for(i in 1:100)
{
  fn <- paste("velocity",i,".txt",sep="")
  dat <- read.csv(fn)
  # ... do your stuff on "dat" here ...
}

HTH,
Jerome

-- 
Jerome Asselin, M.Sc., Agent de recherche, RHCE
CHUM -- Centre de recherche
3875 rue St-Urbain, 3e etage // Montreal QC  H2W 1V1
Tel.: 514-890-8000 Poste 15914; Fax: 514-412-7106



More information about the R-help mailing list