-
-
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
cache and pdfcrop question #105
Comments
Looks like there is a little bug for cleaning up the options when exiting |
should be fixed now; please test. Thanks! |
Thanks - just tested again and I see the same behaviour as described above...using v 0.1.6 |
Also, I noticed that if I set cache=TRUE in SweaveOpts, but have a chunk that has cache=FALSE; that chunk is not evaluated every time I knit, which presumably it is meant to do? Anyway, thanks for looking into these issues! |
No, This sounds like a serious issue, and I will look into it again. |
… are NULL this will cause problems in cache because the chunk options are not what I expected (#105)
How about the latest version now? I tested and did not find either cached chunks to be evaluated twice, or uncached chunks to be skipped. Note before you test, you need to remove the old cache files and start from a new R session to make sure everything is clean. |
I just tried in a fresh R session with the cache cleared and that solves one of the problems i.e. it always runs the cache=FALSE chunks. However, the first pass is OK, second pass re-evaluates everything again (without cropping figs) and the third pass is OK (but does not crop any changed fig chunks). I'll have to see if I can extract a minimal Rnw file that shows this behaviour. |
Yes, I appreciate if you could show me a minimal example. |
Right. I copied your minimal example and replaced the SweaveOpts with that below (which I use in my document) \SweaveOpts{fig.path=figure/manual-,cache.path=cache/test-,fig.align=center,external=TRUE,fig.show=hold,size=small,warning=FALSE,pdfcrop=TRUE,background=1;1;1,echo=TRUE,cache=TRUE} Also added knit_hooks$set(pdfcrop = hook_pdfcrop) in you setup chunk. In a fresh R session/no cache I knit it and it crops. Correct. knit again and it evaluates all but the setup chunk again (I waited a minute just so the time-stamp would change...) change one of the 'boring-plots' chunks, knit again it runs the chunk but does not crop. Hope that helps! And if it matters this is R 2.14.1 on 64bit Windows. |
OK, I believe the culprit is If
As the second to last paragraph in the Cache section mentioned, you should be careful with chunks that have side-effects -- in most cases, you must not cache them. |
Ah! I see...that is quite a subtle effect and it does explain all the behaviour I see. I am careful with my main chunks, but that early set-up chunk can easily be forgotten. Given the importance of that first set-up chunk in potentially affecting the whole document it might be worth adding cache=FALSE in your example documents as an aid memoir and to prevent others accidently doing what I did and basing a document on one of yours? Anyway, great to have nailed that - so thanks very much! |
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. |
I'm using knitr_0.1.5 on a document and in my SweaveOpts I have pdfcrop=TRUE and cache=TRUE. I also have knit_hooks$set(pdfcrop = hook_pdfcrop) early on.
When I first knit the document it correctly evaluates all chunks and crops them. If I immediately knit the document again it evaluates all the chunks again (not expected) - but does not crop them. On a third pass it does not evaluate anything (which is expected). Then if I change a chunk it evaluates it but does not crop the pdf...
A typical chunk would be like:
So - something a bit odd somewhere. Earlier versions (pre 0.1 I think...) worked OK as far as I can tell.
Thanks
David
The text was updated successfully, but these errors were encountered: