Reputation: 7327
I have /path/to/my/file.tstv
:
Date Pr Data
2016-07-27 0.45 "Prior 1."
2016-07-28 0.55 "Prior 2."
2016-07-29 0.65 "Prior 3."
And, with my R code:
table_variable <- read.table("/path/to/my/file.tsv", header=TRUE)
Question: How do I instead read this data directly into table_variable
as an inline multiline string?
Something like:
table_variable <- read.table("
Date Pr Data
2016-07-27 0.45 "Prior 1."
2016-07-28 0.55 "Prior 2."
2016-07-29 0.65 "Prior 3."
", header=TRUE)
Upvotes: 0
Views: 63
Reputation: 37661
This does what you want. The main point is the text=
. Notice that I changed your surrounding double quotes to single quotes.
table_variable <- read.table(text=
'Date Pr Data
2016-07-27 0.45 "Prior 1."
2016-07-28 0.55 "Prior 2."
2016-07-29 0.65 "Prior 3."
', header=TRUE)
Upvotes: 3