[R] Sweave and printing error
Vincent Goulet
vincent.goulet at act.ulaval.ca
Wed Mar 26 06:59:21 CET 2008
Le mar. 25 mars à 17:12, Christophe Genolini a écrit :
> Hi the list.
>
> I am writing a tutorial for my student using LaTeX and sweave. I
> include
> some example that work (obiously) but I would also like to include
> some
> example that do NOT work (for pedagogie)...
> Is it possible ?
>
> At this point, I find that :
> - if there is a error in the code, Sweave stop
> - if I put the error in try(), Sweave compile but does not print the
> error as output.
>
> Any solution ?
>
> Thanks a lot
>
> Christophe
Something along these lines should do what you want:
<<echo=TRUE, eval=FALSE>>=
TRUE <- 3
@
<<echo=FALSE, eval=TRUE>>=
cat(try(TRUE <- 3))
@
If I recall correctly, this was discussed here before.
HTH
---
Vincent Goulet, Associate Professor
École d'actuariat
Université Laval, Québec
Vincent.Goulet at act.ulaval.ca http://vgoulet.act.ulaval.ca
More information about the R-help
mailing list