Is there any way that R can be programmed so that it will cycle through all files in a directory without having to define file names? The reason I ask is because I will have about 50-100 files in a directory which will be randomly named. ie: MIDEX, OACES-CO2, ODEN91, etc... If not...are there any languages out there that will do this sort of things? Or is there another method you could recommend for handling the problem? Thanks, Matt -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Wed, 12 Jun 2002, MATT BORKOWSKI wrote: %Is there any way that R can be programmed so that it will cycle through %all files in a directory without having to define file names? The reason I ask %is because I will have about 50-100 files in a directory which will be randomly %named. ie: MIDEX, OACES-CO2, ODEN91, etc... have you checked list.files() ? % %If not...are there any languages out there that will do this sort of things? Or is %there another method you could recommend for handling the problem? % %Thanks, %Matt % % %-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- %r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html %Send "info", "help", or "[un]subscribe" %(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch %_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ % *********************************************************************** Jens Nieschulze Institute for Forest Biometrics & Phone: ++49-551-39-12107 Applied Computer Science Fax : ++49-551-39-3465 Buesgenweg 4 37077 Goettingen E-mail: jniesch at uni-forst.gwdg.de GERMANY http://www.uni-forst.gwdg.de/~jniesch -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
"MATT BORKOWSKI" <mpb170 at psu.edu> writes:> Is there any way that R can be programmed so that it will cycle through > all files in a directory without having to define file names? The reason I ask > is because I will have about 50-100 files in a directory which will be randomly > named. ie: MIDEX, OACES-CO2, ODEN91, etc... > > If not...are there any languages out there that will do this sort of things? Or is > there another method you could recommend for handling the problem?For what purpose? Will "for (i in list.files(....)) ..." do? -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
MATT BORKOWSKI wrote:> > Is there any way that R can be programmed so that it will cycle through > all files in a directory without having to define file names? The reason I ask > is because I will have about 50-100 files in a directory which will be randomly > named. ie: MIDEX, OACES-CO2, ODEN91, etc... > > If not...are there any languages out there that will do this sort of things? Or is > there another method you could recommend for handling the problem?list.files() will help ... Uwe -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
MATT BORKOWSKI <mpb170 at psu.edu> writes:>Is there any way that R can be programmed so that it will cycle through >all files in a directory without having to define file names? The reason I ask >is because I will have about 50-100 files in a directory which will be randomly >named. ie: MIDEX, OACES-CO2, ODEN91, etc... > >If not...are there any languages out there that will do this sort of things? Or >is >there another method you could recommend for handling the problem?Something like: cycle <- function(file.path = ".", file.pattern = "*.dat") { files.2.process <- dir(path = file.path, pattern = file.pattern) for(file.name in files.2.process) { current.file <- read.table(file.name, header = TRUE) # # now do something with this data ... # } } Does it for me. The file.pattern parameter takes regular expressions. Mark -- Mark Myatt -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._