7

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}
```
Mark Heckmann
  • 10,943
  • 4
  • 56
  • 88

1 Answers1

7

You should use a different label like

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

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

Yihui Xie
  • 28,913
  • 23
  • 193
  • 419