Dear all,

I found one possible solution using a single call to write.table:

# assuming that mylist is a named list of data.frames:
data(Orange)
mylist=list(Orange1=Orange,Orange2=Orange,Orange3=Orange)

sapply(1:length(mylist),
      function(x){
                write.table(
                        
data.frame(mydf=rep(names(mylist)[[x]],dim(mylist[[x]])[1]),mylist[[x]]),
                        sep="\t",append=T,file="My.data.frames.txt")
}
)


Best wishes,
Christoph




> Dear R helpers,
>
> Suppose I have a list of data frames. How can I export them
> (e.g. as a
> text file) without losing the columns of the individual
> data.frames?
>
> Example:
>
> data(Orange)
> mylist=list(Orange1=Orange,Orange2=Orange,Orange3=Orange)
>
>
> I would like to use something like
>
> write(mylist,"mylist.txt")
>
> or
>
> format (mylist...)
>
> But somehow I cannot get the information contained in
> "mylist" exported
> in a nicely looking way. Any ideas? Many thanks for any
> help!
>
> Best wishes,
> Christoph
>
>
> (using R 2.11.0 on Windows XP)

______________________________________________
R-help@r-project.org 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 via email to