[R] iterating over files in a directory with R
Roger D. Peng
rpeng at jhsph.edu
Sun Feb 8 22:34:58 CET 2004
I usually do something like this:
filelist <- dir(path = ".") ## files in current directory
for(filename in filelist) {
do.something(filename)
}
-roger
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 }
>
> Could someone please give me a pointer to how (or if) this might be done with R - I haven't yet been able to find anything relevant in the manuals. Or would I need to call each file with some language such as Java and then use R once I have the file name?
>
> Thanks for your help,
>
> femke
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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
>
More information about the R-help
mailing list