opts_current: how does it work in knitr?

2020-03-30 04:37发布

问题:

I am trying to set up different figure size in different chunks. I first define a global settings using:

opts_chunk$set(fig.width=7, fig.height=7)

Then, for the specific chunks, I use:

opts_current$set(fig.width=7, fig.height=14)

But the later is always neglected. So, how does opts_current really work?

回答1:

For specific code chunks, put the chunk options in the chunk header, e.g.

```{r fig.width=7, fig.height=14}

These are called local chunk options, which will override global chunk options (temporarily for this specific chunk).



标签: r knitr