Message-ID: <4026AB82.7060206@jhsph.edu>
Date: 2004-02-08T21:34:58Z
From: Roger D. Peng
Subject: iterating over files in a directory with R
In-Reply-To: <003601c3ee87$9eff4130$72180281@jawks2>
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
>