Re: [R] repeating the same procedure with a number of files within a directory

From: jim holtman <jholtman_at_gmail.com>
Date: Fri 01 Sep 2006 - 17:02:22 GMT

Just have to use a 'for' loop;

for (i in list.files()){

     x <- read.table(i)  # read in the next file (this is in 'i')
     ....compute & write your distance matrix.....
}

On 9/1/06, Ffenics <ffenics2002@yahoo.co.uk> wrote:
> Hi there
> I am very new to R so dont know much about the programming side of thing yet. I've worked out how to input a data matrix, create distance matrices and print them to an external file but only for one data matrix at a time.
>
> I actually have a batch of data matrices for which I want to create distance matrices for each in turn and then print these distance matrices to their respective external files. (I'm wanting them printed as CSV files for processing in excel).
>
> How easy is it to get R to read in files one at a time from a directory and do the same thing with all of those files in turn? And could someone please give me some advice as to how I may go about achieving this if its possible? It would be much appreciated
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.
>

-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

______________________________________________
R-help@stat.math.ethz.ch 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.
Received on Sat Sep 02 03:28:03 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 07 Sep 2006 - 07:51:17 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.