Re: [R] Edit function

From: François Pinard <pinard_at_iro.umontreal.ca>
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) {
    on.exit(sink())
    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   http://pinard.progiciels-bpi.ca

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
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 https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.