iterating over files in a directory with R
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