knitr - Is it possible to call external R script from R markdown (.Rmd) in RStudio? -
it's trivial load external r scripts per this r sweave example:
<<external-code, cache=false>>= read_chunk('foo-bar.r') @
can same done r markdown?
yes.
put @ top of r markdown file:
```{r setup, echo=false} opts_chunk$set(echo = false, cache=false) read_chunk('../src/your_code.r') ```
delimit code following hints knitr
(just @yihui in example):
## @knitr part1 plot(c(1,2,3),c(1,2,3)) ## @knitr part2 plot(c(1,2,3),c(1,2,3))
in r markdown file, can have snippets evaluated in-line:
title ===== foo bar baz... ```{r part1} ``` more foo... ```{r part2} ```
Comments
Post a Comment