rknitr

R/knitr: How to cancel knitting without creting a document at all?


There is knit_exit(), but is there a way to exit knitting and not to write a document at all? The already processed part of the Rmd file should be just ignored.

I have implemented all the analysis and formatting into the Rmd files and I prefer not to separate the analysis into different file from the Rmd file.


Solution

  • I ended up checking the file created by knitr::knit() and deleting it with R unlink() in case the file did not meet certain criteria (errors, too short). In this case there were data-related conditions for creating the file and those could be known only while deep inside the .Rmd file.