Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

duplicate chunk labels emit error #408

Copy link
Copy link
Open
@LiNk-NY

Description

@LiNk-NY
Issue body actions

Hi!

Thanks for the great resource the cookbook is.

This section in the cookbook states that one can use the same chunk label in another chunk.
https://bookdown.org/yihui/rmarkdown-cookbook/reuse-chunks.html#same-label

When I try doing this in practice, I get an error.
Here is an example with a file test.Rmd:

---
title: "Testing Rmd Format"
vignette: |
  %\VignetteIndexEntry{Testing Rmd Format}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r loading, eval=FALSE}
# this is a chunk
1 + 1
```

```{r loading, eval=TRUE}

```

Leads to the error:

> rmarkdown::render("test.Rmd")
processing file: test.Rmd
Error in parse_block(g[-1], g[1], params.src, markdown_mode) : 
  Duplicate chunk label 'loading', which has been used for the chunk:
# this is a chunk
1 + 1

The error also occurs when running R CMD build on a package.

PS. I am aware of options(knitr.duplicate.label = 'allow') but this is not possible for external build systems (e.g., CRAN).

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.