question about 'write.table'

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

question about 'write.table'

karena
I have a question about the "write.table"

I have 100 data.frames, loci1, loci2, loci3.............,loci100.
now, I want to print these data.frames to 100 separate files, and the names of the files are also loci1, loci2, loci3,......., loci100.

how to perform this under a "for" loop?
say,
for (i in 1:100) {
   write.table(...., file='...', ........)
}

thank you,

karena

Reply | Threaded
Open this post in threaded view
|

Re: question about 'write.table'

jholtman
for (i in 1:100){
   write.table(get(paste('loci', i, sep='')), file=paste('loci', i, sep=''))
}

On Tue, May 4, 2010 at 5:02 PM, karena <[hidden email]> wrote:

>
> I have a question about the "write.table"
>
> I have 100 data.frames, loci1, loci2, loci3.............,loci100.
> now, I want to print these data.frames to 100 separate files, and the names
> of the files are also loci1, loci2, loci3,......., loci100.
>
> how to perform this under a "for" loop?
> say,
> for (i in 1:100) {
>   write.table(...., file='...', ........)
> }
>
> thank you,
>
> karena
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/question-about-write-table-tp2126309p2126309.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>



--
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: question about 'write.table'

Muhammad Rahiz
In reply to this post by karena
This could work

out <- c()
for (a in 1:10){
out[a] <- paste("loci",a,sep="")
write.table(out[a],file=out[a],row.names=FALSE,col.names=FALSE)}


Muhammad




karena wrote:

> I have a question about the "write.table"
>
> I have 100 data.frames, loci1, loci2, loci3.............,loci100.
> now, I want to print these data.frames to 100 separate files, and the names
> of the files are also loci1, loci2, loci3,......., loci100.
>
> how to perform this under a "for" loop?
> say,
> for (i in 1:100) {
>    write.table(...., file='...', ........)
> }
>
> thank you,
>
> karena
>
>
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: question about 'write.table'

karena
In reply to this post by jholtman
Thank both of you guys!!