[R] processing all files with certain extension in a directory
Remko Duursma
remkoduursma at gmail.com
Fri Jan 15 12:54:50 CET 2010
Albert,
try something like this:
extfiles <- list.files(pattern=".ext")
for(f in extfiles){
process.data(f)
#etc
}
greetings,
Remko
-------------------------------------------------
Remko Duursma
Post-Doctoral Fellow
Centre for Plants and the Environment
University of Western Sydney
Hawkesbury Campus
Richmond NSW 2753
Dept of Biological Science
Macquarie University
North Ryde NSW 2109
Australia
Mobile: +61 (0)422 096908
www.remkoduursma.com
On Fri, Jan 15, 2010 at 10:43 PM, Albert Vilella <avilella at 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 at 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.
>
More information about the R-help
mailing list