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

后端 未结 1 1565
没有蜡笔的小新
没有蜡笔的小新 2021-01-12 04:47

For documentary purposes, I want some code for a plot in the html-output, but not the plot. Later, I have to call the plotting code, and add something to the plot, but only

1条回答
  •  南笙
    南笙 (楼主)
    2021-01-12 04:55

    Chunk references in <<>> do not respect chunk options, so <> will not work. What you can do is to move the chunk option echo back to the main chunk like this:

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

    echo=-1 means do not echo the first expression (as documented). This is probably what you want:

    screen shot of knitr output

    0 讨论(0)
提交回复
热议问题