[R] iterating over files in a directory with R
Thomas Lumley
tlumley at u.washington.edu
Sun Feb 8 22:34:19 CET 2004
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
More information about the R-help
mailing list