Re: [R] Edit function

From: François Pinard <>
Date: Thu 08 Jun 2006 - 04:44:06 EST

[Pikounis, Bill [CNTUS]]

> view <- function(x) {
> warnopt <- options()$warn
> options(warn=-1)
> on.exit({sink(); options(warn=warnopt)})
> edit(x)
> invisible()
> }

I'm surprised by the necessity of "sink()". Presuming it is necessary indeed, the above could be simplified a bit like this (untested) code:

  view <- function(x) {
    invisible(suppressWarnings(edit(x)))   }

The documentation for "suppressWarnings" is not overly clear about if the "warn" option is restored or not in case of error. It says:

     'suppressWarnings' evaluates its expression in a context that
     ignores all warnings.

My exegesis :-) for that sentence would be that the context does not survive the error, and so, the "warn" option is not changed.

François Pinard

______________________________________________ mailing list
PLEASE do read the posting guide!
Received on Thu Jun 08 04:57:58 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 08 Jun 2006 - 06:10:52 EST.

Mailing list information is available at Please read the posting guide before posting to the list.