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
    Commented Oct 2, 2013 at 1:47
  • @Yihui Can you post your comment as an answer?
    – scottkosty
    Commented Jan 12, 2014 at 12:43
  • @scottkosty of course :)
    – Yihui Xie
    Commented Jan 14, 2014 at 3:57

1 Answer 1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .