Re: [R] setting options only inside functions

From: Jeremy Hetzel <jthetzel_at_gmail.com>
Date: Wed, 27 Apr 2011 06:25:01 -0700 (PDT)


See ?on.exit

Jeremy

On Wednesday, April 27, 2011 9:16:13 AM UTC-4, Jannis wrote:
>
> Dear list members,
>
>
> is it possible to set some options only inside a function so that the
> original options are restored once the function is finished or aborted due
> to an error? Until now I do something like:
>
>
> dummy=function()
> {
> old.options=options(error=dummy1())
>
> ....
>
> options(old.options)
> }
>
>
> This works for most cases but when the function terminates because of an
> error and its last command is not run, error=dummy1() still remains as an
> option. Is there any way around this?
>
>
> Cheers
> Jannis
>
>
> ______________________________________________
> R-h..._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.
>
>



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 27 Apr 2011 - 13:29:42 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 27 Apr 2011 - 13:30:33 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