-
-
Notifications
You must be signed in to change notification settings - Fork 878
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chunk names must be unique between knitr documents in same directory #875
Comments
Thanks for the feedback! That is exactly what the rmarkdown package does by default. Different .Rmd will use different figure/cache directories. You can also set |
Thank you! Also: spectacular work on this package. Its been enormously useful, and a lot of fun to use. |
Thanks for the kind words! :) |
I'd vote to re-open this, and take one of @vtrubets suggestions. This is a major gotcha, and just because rmarkdown does it right doesn't mean that knitr doesn't need to: there's good reasons to use knitr without rmarkdown on top of it. |
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary. |
This may be a user error/workflow problem rather than an issue with knitr itself, but I was just burned by this.
If you have multiple knitr documents (say Rmarkdown files) in a single directory all chunks producing figures should have unique names between those documents! My workflow consists of writing .Rmd documents, converting those to regular Markdown, and using pandoc to produce a final PDF. From what I can tell, this is a pretty common workflow.
If .Rmd files produce figures with the same chunk name, then only the last figure produced remains in figure/. That means that all subsequent conversions from .md to .pdf reference only one version of a figure. This breaks the tie between the final document, and the code used to generate it.
It may be worth naming files in figure/ in such a way that they are explicitly tied to a report. Not sure what the cleanest solution would be: perhaps appending a short hash of the report file name to the .png file name. Alternatively, you could simple warn users that a file in figure/ already exists with that name and suggest they rename their chunk.
The text was updated successfully, but these errors were encountered: