this is supposed to be a trivial thing, but I have not found anything googling it.
I have the following data in a csv file
test.csv
var1,var2
'a',1
'b',2
which I read into R with
d <- read.csv('test.csv')
This there a way for me to insert the content of the csv file in my R code? Something like:
d <- read.csv(
'var1,var2\n
'a',1\n
'b',2')
(above syntax does not work)
how can I tell R that the input string should be treated as the data itself instead of a file name containing it?
This would be for adding small tables to Rmarkdown without having to create a bunch of auxiliary files
of course I could add the same info with
d <- data.frame(
var1=c('a','b'),
var2=1,2
)
but listing the data vector by vector slow the process down. The row by row structure of the csv is easyer
Try this