Re: [R] Sweave and printing error

From: Vincent Goulet <vincent.goulet_at_act.ulaval.ca>
Date: Wed, 26 Mar 2008 01:59:21 -0400

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@act.ulaval.ca   http://vgoulet.act.ulaval.ca

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Wed 26 Mar 2008 - 06:04:04 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 26 Mar 2008 - 08:30:25 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive