R console: When I call source(\"file_of_functions.R\",echo=TRUE)
, all source file expressions, including comments, print to console.
test.Rmd
---
output: html_document
---
```{r}
options(prompt = '> ')
```
```{r}
source('./test.r', echo = TRUE)
```
```{r}
source('./test.r', echo = TRUE, keep.source = TRUE)
```
I don't mean to post this as an answer, but I just want to point out the possibility that you can easily insert test.r
into a code chunk using
```{r code=readLines('test.r')}
```
Personally I think this is much nicer than using source()
, e.g. you don't get the prompts >
by default (you can if you want), and the R code will be syntax highlighted. Of course, your comments will be preserved.