Console R: When I call source("file_of_functions.R",echo=TRUE) , all expressions of the source file, including comments, are output to the console.
Knit HTML: When I put source("file_of_functions.R",echo=TRUE) in a piece and knit in html, the same output is output with the exception of comments.
For clarity of my code and report, I would like the comments of the source file to be included in the html report.
Any suggestions?
Basic example: Save the following as fR:
# function to add a number to itself f <- function(x) x+x f(2)
In the console, a call to source("fR",echo=TRUE) prints:
#function to add a number to itself > f <- function(x) x+x > f(2) > [1] 4
When knitting in html call
```{r} source("fR",echo=TRUE) ```
gives the same result, but without comment.
r knitr
Jonathan chipman
source share