Re: [R] loop and read.table

About this list Date view Thread view Subject view Author view Attachment view

From: Gabor Grothendieck (ggrothendieck@myway.com)
Date: Sat 27 Dec 2003 - 02:37:03 EST


Message-id: <20031226153703.2CCE63950@mprdmxin.myway.com>


And if your intention is to create 4 data frames with
names tab1, tab2, tab3, tab4 then combine Prof. Riley's
advice with assign like this:

for(i in 1:4)
   assign( paste("tab", i, sep=""),
           read.table(paste(i, "txt", sep=".")) )

---
Date: Fri, 26 Dec 2003 14:07:45 +0000 (GMT) 
From: Prof Brian Ripley <ripley@stats.ox.ac.uk>
To: lefebure tristan <lefebure@univ-lyon1.fr> 
Cc: <r-help@stat.math.ethz.ch> 
Subject: Re: [R] loop and read.table 

On Fri, 26 Dec 2003, lefebure tristan wrote:

> I would like to open several tables with a loop, using something like : > ----------------- > $ ls > 1.txt 2.txt 3.txt 4.txt > $ R > > for (i in 1:4) tabi<-read.table("i.txt")

Use read.table(paste(i, "txt", sep="."))

> Error in file(file, "r") : unable to open connection > In addition: Warning message: > cannot open file `i.txt' > ------------------

______________________________________________ R-help@stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Thu 01 Jan 2004 - 09:21:04 EST