[R] Running R Script on a Sequence of Files

Philipp Pagel p.pagel at wzw.tum.de
Fri Dec 5 20:30:03 CET 2008

>  I can't believe the two 'solutions' already posted. It's easy:

Me neither.
>  ?list.files

That's what I would use, too. If the OP is on a UNIX platform,
run the R-script in a loop in the shell is an alternative.
Something like this (bourne shell syntax):

for datafile in *.csv ; do
	Rscript analyze.R $datafile

The R script (analyze.R) can use commandArgs() to read the filename


Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany

More information about the R-help mailing list