[R] Iterative process for reading in text files

Manuel Morales Manuel.A.Morales at williams.edu
Fri Apr 29 13:29:20 CEST 2005


Hi Meredith,

When I've wanted to do this, I put all my files (group1.txt,
group2.txt ...) in a separate directory. Then, running R from that
directory:

files<-list(files)

for (i in 1:length(files)) {
group<-read.table(files[i],header=T)
do stats here
}

On Fri, 2005-04-29 at 15:17 +1000, Briggs, Meredith M wrote:
> Hello
> 
> Instead of reading in group1.txt I want to read in groups1 for the first iteration of i, then groups2 for the second and so on. Obviously I can't use groups(i) but assume there is a way to do this.
> 
> group<-read.table("C:/Data/April 2005/group1.txt",header=T)
> 
> thanks in advance
> 
> Meredith
> 
> ______________________________________________
> R-help at 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




More information about the R-help mailing list