[R] on.exit
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Thu Sep 27 20:47:56 CEST 2001
kjetil halvorsen <kjetilh at umsanet.edu.bo> writes:
> but what should be better, doesnt work:
>
> > test1 <- function() {
> + oldwarn <- options("warn")
> + options(warn=-1)
> + on.exit( options(warn=oldwarn))
> + log(-1)
> + }
> > test1()
> Error in options(...) : warn parameter invalid
> >
>
>
> What is wrong? (I have tried other versions, without success)
oldwarn is a list. Try
> fix(test1)
> test1()
[1] NaN
> test1
function() {
oldwarn <- options("warn")
options(warn=-1)
on.exit( options(warn=oldwarn$warn))
log(-1)
}
or maybe
oldwarn <- unlist(options("warn"))
...
on.exit(options(warn=oldwarn))
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list