问题
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