From: Uwe Ligges (ligges@statistik.uni-dortmund.de)
Date: Sat 27 Dec 2003 - 01:02:25 EST
Message-id: <3FEC3F71.1030801@statistik.uni-dortmund.de>
lefebure tristan wrote:
> Hi,
> 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")
Since i is within a character string, it cannot be used as a variable in
your case. You may paste() is together: paste(i, ".txt", sep=""), or
even better, read the directories contents with list.files() and proceed
over the result as in:
tab <- lapply(list.files(pattern="^?[[:digit:]]\.txt"), read.table)
Uwe Ligges
> Error in file(file, "r") : unable to open connection
> In addition: Warning message:
> cannot open file `i.txt'
> ------------------
>
> thanks for any help
>
> Tristan Lefebure
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
This archive was generated by hypermail 2.1.3 : Thu 01 Jan 2004 - 09:21:04 EST