Message-ID: <Pine.A41.4.58.0402081332430.139062@homer01.u.washington.edu>
Date: 2004-02-08T21:34:19Z
From: Thomas Lumley
Subject: iterating over files in a directory with R
In-Reply-To: <003601c3ee87$9eff4130$72180281@jawks2>
On Sun, 8 Feb 2004, femke wrote:
> Hello,
>
> I'm an R newbie and was wondering whether there are R commands for
> iterating over files in a directory. Basically what I want to do is to
> iterate over many files and apply some R functions to each file
> seperately.
>
> e.g. for (each file in a directory) do { some R calculation with the
> info in that file }
>
sapply(list.files("a directory"), some.R.calculation)
or
files<-list.files("a directory")
for(each.file in files){
some.R.calculation
}
-thomas