Dear JJ and list members,

I wonder whether it's possible to get scan() to read in-line data in an R 
Markdown document. The following code, for example, works (of course) when 
entered in the R console but fails in an R block in an R Markdown document 
(using an up-to-date version of RStudio):

```{r}
x <- scan()
1 2 3
4 5 6

x
````

I'm aware of a couple of work-arounds, such as putting the data in a file or a 
character string (as below), but am interested in whether it's possible to get 
this to work directly.

```{r}
text <- "
1 2 3
4 5 6
"
(x <- scan(file=textConnection(text)))
````

Any help would be appreciated.

John

------------------------------------------------
John Fox, Professor
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/

______________________________________________
R-help@r-project.org mailing list
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