Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can a data frame be transformed into a string with a csv format on R?

Tags:

dataframe

r

csv

I don't want to write a csv into a file, but to get a string representation of the dataframe with a csv format (to send it over the network).

I'm using R.NET, if it helps to know.

like image 251
Lay González Avatar asked Oct 29 '25 17:10

Lay González


1 Answers

If you are not limited to base functions, you may try readr::format_csv.

library(readr)
format_csv(iris[1:2, 1:3])
# [1] "Sepal.Length,Sepal.Width,Petal.Length\n5.1,3.5,1.4\n4.9,3.0,1.4\n"
like image 179
Henrik Avatar answered Oct 31 '25 07:10

Henrik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!