[R] processing all files with certain extension in a directory

Albert Vilella avilella at gmail.com
Fri Jan 15 12:43:57 CET 2010


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.



More information about the R-help mailing list