When running chunks of an rmarkdown interactively using RStudio, the console output is visible. Therefore if an error happens, it can be debugged. When run headlessly, the only console output is the progress meter that tells which chunks have run and finished. That is helpful to a point, but it doesnt show where in the crunk the error happened. Are there any mechanism to capture the output from the partially executed chunk, when rmarkdown::render() is used? I realize that it is possible to debug a markdown by splitting apart chunks, etc.; however, that's not always an option.
Below is an example markdown to illustrate this (i am not sure how to escape the backtics . If you run this file interactively in RStudio, you see the console output, which shows exactly where it died. if you run on the command line or via "rmarkdown::render()", you only get the message "Quitting from lines 17-26", which is not always useful to diagnose a problem.
---
title: "RMarkdown Error Repro"
---
# NOTE: backticks "escaped" so they will render in this codeblock.
\```{r chunk1}
print('I worked')
\```
\```{r chunk2}
print('This worked')
# Code will stop here, but no information is printed to console when run headless using rmarkdown::render()
stop('error')
print('This will not run')
\```
Again, if you run the above rmd file using "rmarkdown::render('myFile.rmd')", the only information is "Quitting from lines 17-26". Seeing the fact that the line "print('This worked')" printed would be helpful to diagnose which line failed, as would the actual error message.
Thanks for any help.