It's really not a job for the write.* functions, but for the string-handling functions.
Here's a slightly clunky possibility: # use your example s.df <- read.csv(text='cola,colb\n1,2\n2,3\n') # turn a data frame into a string paste( paste(colnames(s.df), collapse=","), paste(apply(s.df, 1, paste, collapse=","), collapse="\n"), sep="\n") On Thu, Mar 12, 2015 at 1:15 PM, Thomas Nyberg <tomuxi...@gmail.com> wrote: > 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 -- Sarah Goslee http://www.functionaldiversity.org ______________________________________________ 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.