[R] Reading in multiple files in a loop

From: Zu Thur Yew <fbszty_at_leeds.ac.uk>
Date: Thu, 27 Mar 2008 15:40:26 +0000


I'm new to R and want to use it to analyse a number of data files (e.g. 100).
I want to read in multiple files in a loop in a specific order (e.g. 1 to 100) and was hoping to do something like:

for (r in 1:100) {
 d1 <-read.table(r.anl)
  for (r2 in 1:100) {
   d2 <-read.table(r2.anl)
    cc <-cor(d2,d1)

>From my basic understanding of R, it requires "" in read.table and so, r
and r2 would not be substituted.
Is there a better way to read in multiple files in an order that preserves "numerical" order (e.g. 1.anl, 2.anl, 3.anl, 4.anl etc)?



        [[alternative HTML version deleted]]

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. Received on Thu 27 Mar 2008 - 19:53:15 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 27 Mar 2008 - 20:30:24 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.

list of date sections of archive