reusing chunks that include plotting with knitr .Rmd

空扰寡人 提交于 2019-12-22 04:55:28

问题


When a chunk that includes plotting is reused the plots are not referenced properly, i.e. they are identical for both chunks though they are supposed to be different. What can I do about it?

## Test

```{r}
col <- "black"
```

```{r chunk1}
plot(0, col=col)
```

```{r}
col <- "red"
```

```{r chunk1}
```

回答1:


You should use a different label like

```{r chunk2, ref.label='chunk1'}
```

See http://yihui.name/knitr/demo/reference/



来源:https://stackoverflow.com/questions/11080793/reusing-chunks-that-include-plotting-with-knitr-rmd

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