Re: [R] export list to csv

2011-03-16 Thread andrija djurovic
Thanks everyone for different solutions. Every solution works very well. For my purpose, this function sink does what I was looking for. Andrija On Wed, Mar 16, 2011 at 4:23 PM, Roman Luštrik wrote: > How about? > > sink("andrija.csv") > l > sink() > > -- > View this message in context: > http:

Re: [R] export list to csv

2011-03-16 Thread Kenn Konstabel
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 sa

Re: [R] export list to csv

2011-03-16 Thread Roman Luštrik
How about? sink("andrija.csv") l sink() -- View this message in context: http://r.789695.n4.nabble.com/export-list-to-csv-tp3381992p3382062.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat

Re: [R] export list to csv

2011-03-16 Thread Ivan Calandra
Hi, You could try this (others surely have better solutions): out_file <- file("file.csv", open="a") #creates a file in append mode for (i in seq_along(l)){ write.table(names(l)[i], file=out_file, sep=",", dec=".", quote=FALSE, col.names=FALSE, row.names=FALSE) #writes the name of the list

Re: [R] export list to csv

2011-03-16 Thread andrija djurovic
Soryy, I didn't explain well what I want. I would like to have a table in csv on txt file like this: $A q1q2 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 Dallazua

Re: [R] export list to csv

2011-03-16 Thread Henrique Dallazuanna
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 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))) >

[R] export list to csv

2011-03-16 Thread andrija djurovic
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. D