Re: [Rd] setting option in function

From: Charles Geyer <charlie_at_stat.umn.edu>
Date: Fri, 19 Oct 2012 18:02:45 -0500

That was easy. Thanks. That will fix a problem a lot of users are having with the aster package. If users have NA's in their data, then they almost certainly don't know what they are doing (with aster).

On Fri, Oct 19, 2012 at 5:10 PM, Thomas Lumley <tlumley_at_uw.edu> wrote:

> old_options <- options(na.action=na.fail)
> on.exit(options(old_options))
>
> You can also use this to define a wrapper that executes an expression
> using special options
>
> withOptions<-function(optlist,expr){
> oldopt<-options(optlist)
> on.exit(options(oldopt))
> expr<-substitute(expr)
> eval.parent(expr)
> }
>
>
> -thomas
>
>
>
> On Sat, Oct 20, 2012 at 10:35 AM, Charles Geyer <charlie_at_stat.umn.edu>
> wrote:
> > is it possible to set an option inside a function ((I want to set
> > na.action = na.fail) and have the previous state restored if there is
> > an error so that the function doesn't change the option behind the
> > user's back?
> >
> > Sorry if this has been answered before, but this subject is hard to
> Google.
> >
> > --
> > Charles Geyer
> > Professor, School of Statistics
> > University of Minnesota
> > charlie_at_stat.umn.edu
> >
> > ______________________________________________
> > R-devel_at_r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
>
>
>
> --
> Thomas Lumley
> Professor of Biostatistics
> University of Auckland
>

-- 
Charles Geyer
Professor, School of Statistics
University of Minnesota
charlie_at_stat.umn.edu

	[[alternative HTML version deleted]]

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Fri 19 Oct 2012 - 23:24:17 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

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 Sat 20 Oct 2012 - 06:50:47 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive