The optimal way of doing it depends on how you want to use the result. An easy way has been recommended - if you have
boo <- list(first=data.frame(a=1:5, b=2:6), second=data.frame(a=6:10, b=7:11)) .. then sink("boo.txt") boo # or: print(boo) sink() ... will put it all in the same file, the same way it would ordinarily appear on the screen . But this is not a csv file (Comma Separated Values), and it's not easily usable by other software (try re-reading it to R). I think a better way for most purposes would be to make it a big table and add an extra variable (say, GROUP). To do it in one go you might use something like boo <- mapply(function(x,y) within(x, GROUP <- y), boo, names(boo), SIMPLIFY=FALSE) ... then put the different pieces together using something like do.call(rbind, boo) # resulting in something like this: a b GROUP first.1 1 2 first first.2 2 3 first first.3 3 4 first first.4 4 5 first first.5 5 6 first second.1 6 7 second second.2 7 8 second second.3 8 9 second second.4 9 10 second second.5 10 11 second ... and the result is what you can write to a csv file and later easily re-read using any software write.csv(do.call(rbind, boo), "boo.csv") Regards, Kenn On Wed, Mar 16, 2011 at 3:14 PM, andrija djurovic <djandr...@gmail.com>wrote: > Soryy, I didn't explain well what I want. I would like to have a table in > csv on txt file like this: > > $A > q1 q2 > aa 1 3 > bb 2 check > cc check 5 > $B > q1 q2 > aa check 4 > bb 1 5 > The same as write.csv of any data frame. > > > > > On Wed, Mar 16, 2011 at 4:03 PM, Henrique Dallazuanna <www...@gmail.com > >wrote: > > > Use dput: > > > > dput(l, file = "l_str.txt") > > > > Then, to read again: > > > > l <- dget(file = 'l_str.txt') > > > > On Wed, Mar 16, 2011 at 11:55 AM, andrija djurovic <djandr...@gmail.com> > > wrote: > > > Hi everybody. > > > > > > I have list like this: > > > > > > l<-list(data.frame(q1=c(1,2,"check"),q2=c(3,"check",5)), > > > data.frame(q1=c("check",1),q2=c(4,5))) > > > names(l)<-c("A","B") > > > rownames(l[[1]])<-c("aa","bb","cc") > > > rownames(l[[2]])<-c("aa","bb") > > > > > > Every object has the same number of columns but different number of > rows. > > > Does anyone know if it is possible to export such kind of list, into > one > > csv > > > file, and keeping all the names? > > > > > > Thanks in advance > > > > > > Andrija > > > > > > [[alternative HTML version deleted]] > > > > > > ______________________________________________ > > > 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< > http://www.r-project.org/posting-guide.html> > > > and provide commented, minimal, self-contained, reproducible code. > > > > > > > > > > > -- > > Henrique Dallazuanna > > Curitiba-Paraná-Brasil > > 25° 25' 40" S 49° 16' 22" O > > > > [[alternative HTML version deleted]] > > > ______________________________________________ > 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. > > [[alternative HTML version deleted]]
______________________________________________ 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.