title: What is the command in RMarkdown to "source" and display the code from an existing .R file?
body: <p>Example: My R script is named "code.R". It produces a simple plot of y versus x. And looks like this in Rmarkdown.</p>
  
  <pre><code>    ````{r eval=FALSE}
      ## code in "code.R"
      x = 1:10
      y = 1:10
      plot(x,y)
      ```
  </code></pre>
  
  <p>For documentation and reproducibility I want to create a Rmarkdown file which reads "code.R" when knitted from RStudio. (A bit like <i>\include{}</i> in LaTex.) The resulting RMarkdown PDF should thus display a not-evaluated verbatim copy of the R code from "code.R". </p>
  
  <p>The end goal is to make a RMarkdown file which reads dozens of R-files and groups all R-code in one PDF for reproducibility and future reference. This would prevent me to copy-paste the new R code each time I alter the source files.  I am not interested in actually running the R-code in RMarkdown.</p>
  
  <p>Part of a solution (but how?) might be to create a chunk which read the file and stores the read textlines and another chunk which displays these text lines as verbatim code?</p>
  
  <p>Is there an existing build-in RMarkdown command or additional options in <i>````{r eval=FALSE}</i> which produce my intended result? Could you provide an example? </p>
  
  <p>A link to a more complicated Stackoverflow question which addresses my problem indirectly is also appreciated.</p>
  
  <p>Any pointers would be appreciated!!</p>