Rmarkdown - Run code and display errors in documen

2019-04-06 08:03发布

问题:

I get an error message when running the code below which is expected - I would like this to be ran and displayed in the pdf, however the error is returned in r and the code doesn't run.

{r, warning=TRUE} library(survey) debug(withReplicates.svyrep.design)

I have tried warning=TRUE but this doesn't work.

How can I get the error displayed in the document?

回答1:

Add error=TRUE to the chunk options. That will result in the script running to completion with the error appearing in the output.