Stop on error when executing chunks interactively from RMarkdown document

I often use RMarkdown documents interactively within RStudio. They're useful both for the ability to knit output (with optional caching of chunks) but also as a way of compartmentalising code during interactive use.

It would be really useful if the options in the 'Run' menu could be changed so that they stopped on error. At present, if you choose 'Run current chunk' (or any of the other options) and there's an error on the first line, RStudio continues to execute all of the subsequent lines. If you're not careful, the error message can be missed if the subsequent lines execute successfully (though with potentially incorrect results).

Could the functionality be changed so that it works more like 'Source' on a standard R file? This would also fit better with the fact that the 'Ctrl+Shift+Enter' shortcut maps to 'Run current chunk' in an .Rmd file and to 'Source with echo' on a .R file. In case anyone relies on the current functionality, this could be potentially made an option, though I can't really see why anyone would usually want to continue executing code beyond a line with an error.


This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.