Re: [R] Question about Sweave

From: Roger Bivand <>
Date: Tue 28 Feb 2006 - 07:46:19 EST

On Mon, 27 Feb 2006, Elizabeth Purdom wrote:

> Hi,
> I'm not sure if Sweave questions should go to the general list, but it
> seems to be part of the core R package without a separate maintainer.
> I am writing a tutorial for R in a latex file. I'd like to use Sweave,
> since this seems its ideal usage. The problem is that I want to
> purposefully put errors in and then the output that comes with it in the
> text of my tutorial. However the errors kill the function Sweave() in R
> when what I would like is for Sweave to just run it and include the error
> message as part of the output.

> I have set options(error=NULL). It doesn't seem that the error options
> would affect Sweave in the right way, since an error in my .Rnw file causes
> an error in Sweave() itself, not just in the processing of the code, but
> maybe there's an error-handling system I don't know about that would do it.
> (I tried error=expression(NULL) but Sweave couldn't finish regardless). I
> don't see any options in the documentation of Sweave that allow this
> behavior, either.

The usual way is to put the erroneous command inside try(), and mix blocks with echo=FALSE or TRUE and cat() of the object returned by try() of your command. See:

for an example.

> Thanks,
> Elizabeth
> ______________________________________________
> mailing list
> PLEASE do read the posting guide!

Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43

______________________________________________ mailing list
PLEASE do read the posting guide!
Received on Tue Feb 28 07:55:22 2006

This archive was generated by hypermail 2.1.8 : Tue 28 Feb 2006 - 09:08:45 EST