[R] R Markdown and scan()
John Fox
jfox at mcmaster.ca
Sat Oct 25 16:43:49 CEST 2014
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/
More information about the R-help
mailing list