Saving an Rmd with duplicate labels

RStudio fails to save changes to Rmd in cases where the notebook has duplicate labels.

Although the top of the file shows an error as "Error creating notebook: duplicate label 'this label'." it does not make clear that a save failed to happen and the * indicator will go away (as if it did save).

I've lost changes as a result of this. I don't generally care if the html associated with a notebook is generated and don't see why I need unique labels.

As it so happens you do need unique labels (for example, in the notebook you've screenshotted above, the plots generated from those two chunks would overwrite each other because they are named by chunk labels). So, at the very least, a temporary fix would be to use them.

This bit I don't know the answer to – just pointing that out for disambiguation purposes. :slightly_smiling_face:

2 Likes

Awesome. Thanks!

Understood about overwriting the plots, although I'm not actually clear that it could be assumed that might not be a desired behavior in some cases.

Even if that can be assumed, I don't know why it would preclude a save.

My usual attention is to that * in the filename to confirm a save (i.e., munging.Rmd* -> munging.Rmd).

For that to clear, when it fact it failed to save, is troubling to me.

Understood – I just don't know how it works!

1 Like

2 posts were split to a new topic: Resolving Duplicate Labels Error Code Chunk Externalization and Rmarkdown Notebook