I'm writing some R notes with Sweave and would like to show common errors. For example,
<<echo=TRUE, eval=TRUE>>=
x = 5
#Case matters!
x*X
@
However when sweaving, the document won't compile due to the R error. Is there any way to make sweave compile and show the (nicely formated) error?
As Shane suggests, use
<<echo=TRUE,eval=FALSE>>
for the code that will error, but you want to display, and then again with
<<echo=FALSE,eval=TRUE,results=verbatim>>
but with the same code wrapped in a try.
There's an example here: http://tolstoy.newcastle.edu.au/R/help/05/09/11690.html