myloginid
myloginid

Reputation: 1473

Knit HTML - Recover from Error?

I have a pretty long R code that takes approx 2-3 hours to run and Knit to HTML. However even with minor errors or warning.. the Knit aborts.. In the below example it has done so due to savehistory error.

processing file: model_v64.Rmd
  |......................                                           |  33%
  ordinary text without R code

  |...........................................                      |  67%
label: unnamed-chunk-1 (with options) 
List of 1
 $ echo: logi TRUE


Quitting from lines 21-278 (model_v64.Rmd) 
**Error in .External2(C_savehistory, file) : no history available to save**
Calls: <Anonymous> ... withCallingHandlers -> withVisible -> eval -> eval -> savehistory
Execution halted

Is there any way in which we can

  1. Option 1 - Recover the partially created HTML from tmp directories or anywhere else
  2. Option 2 - Get Knit HTML to continue on errors and not halt the code.
  3. Option 3 - atleast save the already Knit HTML and then stop.

Thanks, Manish

Upvotes: 3

Views: 1025

Answers (1)

Yihui Xie
Yihui Xie

Reputation: 30174

Set the chunk option error = TRUE to display the error instead of halting R:

knitr::opts_chunk$set(error = TRUE)

Upvotes: 6

Related Questions