4

I noticed that with a large dataset knitr takes an unexpected long time to compile my document: about 23 minutes from when knitr completes the last chunk to when it writes the .tex. I don't understand what it is doing while taking so long because according to the log this long time span occurs between

  |.................................................................| 100%
   inline R code fragments

and

output file: mydocument.tex

[1] "mydocument.tex"

without knitr echoing anything in the log to give indication of what it is computing.

Looking at when the file was last modified, it appears that the cache from the last chunk has not been updated during this long time span. Actually no file in the document folder/sub-folders is modified during this time.

What is knitr processing just before writing the .tex file? Is there anyway to speed this up through caching? Could help if I set cache=TRUE as default?

3
  • 1
    you can turn on the verbose mode by opts_knit$set(verbose=TRUE), and then you will see what is being computed after you call knit(); basically it shows you the code in \Sexpr{}; cache=TRUE only works for code chunks, and does not work for inline code
    – Yihui Xie
    Oct 2 '13 at 1:47
  • @Yihui Can you post your comment as an answer?
    – scottkosty
    Jan 12 '14 at 12:43
  • @scottkosty of course :)
    – Yihui Xie
    Jan 14 '14 at 3:57
5

You can turn on the verbose mode by opts_knit$set(verbose=TRUE), and then you will see what is being computed after you call knit(). Basically it shows you the code in \Sexpr{}; cache=TRUE only works for code chunks, and does not work for inline code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.