Re: [Rd] setting option in function

2012-10-19 Thread Charles Geyer
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 wrote: > old_options <- options(na.action=n

Re: [Rd] setting option in function

2012-10-19 Thread William Dunlap
Hi Charley, You can use the idiom oldNaAction <- options(na.action=na.fail) on.exit(options(oldNaAction)) or the slightly safer (protected again an interrupt between the first two lines or an error calling options to set them) oldNaAction <- getOption("na.action") on.exit(options(oldNa

Re: [Rd] setting option in function

2012-10-19 Thread Thomas Lumley
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)