theFiles <- list.files(inputdir, full=T, pattern="\\.[eE][xX][tT]$") for (file in theFiles){ ... }
On Fri, Jan 15, 2010 at 11:43 AM, Albert Vilella <avile...@gmail.com> wrote: > Hi all, > > I'm trying to process all files with a certain extension "*.ext" in a > directory like this: > >> R --slave --args /my/dir < dir_plot.r > > where I then I want to do something like: > > myarg <- commandArgs() > inputdir <- myarg[length(myarg)] > print(inputdir) > "for file with extension "*.ext in inputdir" > do > data = process.data(file) > outfile = paste(file,".png",sep="") > png(outfile,width=3200,height=2400) > do.a.plot(data) > dev.off() > done > q() > > How can I do the file looping bit? > > Thanks in advance, > > Cheers, > > Albert. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.