[R] Iterative process for reading in text files

Simon Blomberg Simon.Blomberg at anu.edu.au
Fri Apr 29 07:50:35 CEST 2005


Do you mean that you have one file where the data is ordered by 
group? If so, using scan and a loop is an easy option. If you have 
the data in separate files by group, just make a character vector 
with your filenames as elements and use a loop to read the data using 
read.table at each iteration. Or if they all have similar names such 
as group1.txt, group2.txt, etc. you could construct the filenames on 
the fly using paste.

HTH,

Simon.


>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


-- 
Simon Blomberg, B.Sc.(Hons.), Ph.D, M.App.Stat.
Visiting Fellow
School of Botany & Zoology
The Australian National University
Canberra ACT 0200
Australia

T: +61 2 6125 8057  email: Simon.Blomberg at anu.edu.au
F: +61 2 6125 5573

CRICOS Provider # 00120C




More information about the R-help mailing list