Skip to content
Prev 176089 / 398503 Next

temporarily modify par values?

It would be nice to add exception handling to this, to clean up on
error. Something like unwind-protect in Lisp.

Here's a naive implementation:


 with.par <- function(data, expr, ... ){
   olderror <- getOption("error")
   options(error=function () {
     par(old.par)
     options(error=olderror)
   })
   old.par <- data
   expr
   options(error=olderror)
   invisible(par(old.par))
 }

Is this a reasonable way to do such things? [I'm new to this kind of
stuff in R]

Or is there a 'with.error.handler' or 'with.unwind.protection' wrapper?
;-)

Yours sincerely,