Search code examples
rknitrsweaver-markdown

List the full code of a knitr-type document at the end of the same document


One chunk silently generates output.

```{r, echo = FALSE}
summary(cars)
```

How can the same chunk be automatically listed at the end like this?

```
summary(cars)
```

knitr::purl with an argument eval = FALSE would work if it existed.

It would be ideal to list individual chunks by name.


Solution

  • I have mentioned it in Section 12.1.4 of the first edition of the knitr book, which is basically:

    ```{r ref.label=knitr::all_labels()}
    ```