Hello,

Maybe using text connections. See ?textConnection.

tc <- textConnection("foo", "w")
s <- 'cola,colb\n1,2\n2,3\n'
cat(s, file = tc)
close(tc)
foo

read.csv(text = foo)


Hope this helps,

Rui Barradas

Em 12-03-2015 17:15, Thomas Nyberg escreveu:
Hello,

I've found the following useful functionality:

s <- 'cola,colb\n1,2\n2,3\n'
read.csv(text=s)
   cola colb
1    1    2
2    2    3


But I haven't found a similar option in write.csv. I.e. I would like to
"write" a dataframe to a string. What would be the easiest way to go
about such a thing? Right now I can only think of using a file as an
intermediary, but that seems a bit silly. Thanks for any help.

Cheers,
Thomas Nyberg

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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