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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -