[R] how to read a series of data set

Matt McCall mmccall at mail.nih.gov
Fri Aug 20 18:06:55 CEST 2004


try this maybe?

for (i in 1:100){
test <- read.table(file=paste("m",i,".dat", sep=""))
write.table(test, file=paste("c",i, ".dat", sep=""))
}

GO BLUE!
Matt



On Aug 20, 2004, at 11:44 AM, Yulei He wrote:

> Hi, there.
>
> I want to input and output a bunch of data set. Suppose I want to read
> data set m1.dat, m2.dat, m3.dat,... m100.dat and output c1.dat, 
> c2.dat, ..
> and c100.dat. Notice that the index of data set is from 1 to 100, How 
> can
> I put them into a loop? The code I am thinking is
> that
>
> for (i in 1:100)
> {
>  test=read.table(file="?");
>  write.table(test, file="?");
> }
>
> Any help will be greatly appreicated.
>
> Yulei
>
>
>
> $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
> Yulei He
> 1586 Murfin Ave. Apt 37
> Ann Arbor, MI 48105-3135
> yuleih at umich.edu
> 734-647-0305(H)
> 734-763-0421(O)
> 734-763-0427(O)
> 734-764-8263(fax)
> $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
>
> ______________________________________________
> 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