Respecting global options in knitr

自闭症网瘾萝莉.ら 提交于 2019-12-10 13:12:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!