问题
I am having trouble with setting global options in my R Markdown documents. A simple example follows. In this case I've attempted to set global.par = TRUE
. The expectation is that any par()
specifications I make in one chuck are carried into subsequent chunks. However, this is not happening.
```{r package_options, include=FALSE}
knitr::opts_knit$set(global.par = TRUE)
```
```{r}
lambda <- 0.2; n <- 1000
exp <- rexp(n, lambda)
par(cex = 0.7)
hist(exp)
```
```{r}
lambda <- 0.02; n <- 1000
exp <- rexp(n, lambda)
hist(exp)
```
Specs: Max OS 10.11, R version 3.2.0 (2015-04-16), RStudio 0.98.1062, knitr 1.12.3
回答1:
This issue has been fixed in knitr (>= v1.12.17), and you may test the current development version of knitr on Github. I just discovered that setting mfcol
/mfrow
will reset cex
to 1, and that was the root cause of knitr not being able to restore cex
correctly.
来源:https://stackoverflow.com/questions/35606445/respecting-global-options-in-knitr