r - How to add elements to a plot using a knitr chunk without original markdown output? -


for documentary purposes, want code plot in html-output, not plot. later, have call plotting code, , add plot, seeing additional code. tried this:

```{r non.finished.plotting, eval=false}     plot(1,type="n") ``` explanatory text here in output: "this produces empty plot, , add points manually."  ```{r add.layer, fig.width=5, fig.height=5} <<non.finished.plotting, echo=false>> points(x=rnorm(100,1,0.1), y=rnorm(100,0.8,0.1) )  ``` 

i have found echo-notation @ yihui's, when knit this, error message in output.

## error: plot.new has not been called yet 

i tried fiddling chunk options, not find combination want. (sorry, basic, did not find quite example.)

chunk references in <<>> not respect chunk options, <<non.finished.plotting, echo=false>> not work. can move chunk option echo main chunk this:

```{r add.layer, fig.width=5, fig.height=5, echo=-1} <<non.finished.plotting>> points(x=rnorm(100,1,0.1), y=rnorm(100,0.8,0.1) ) ``` 

echo=-1 means not echo first expression (as documented). want:

screen shot of knitr output


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -