[R] Debug problem
Gabor Grothendieck
ggrothendieck at myway.com
Wed Apr 21 00:58:50 CEST 2004
Consider the following R session under Windows XP Pro. Note that
if we set debugging for function
f then even if we reset its environment it still has debugging on.
Also if we copy f to g then g has debugging; however, if we change
g's environment then g no longer has debugging. Why did f retain
debugging when its environment was changed but g did not?
R : Copyright 2004, The R Foundation for Statistical Computing
Version 1.9.0 (2004-04-12), ISBN 3-900051-00-3
[...snip...]
Type 'q()' to quit R.
> f <- function(x) { x }
> f(1)
[1] 1
> debug(f)
> f(1)
debugging in: f(1)
debug: {
x
}
Browse[1]> Q
> environment(f) <- new.env()
> f(1)
debugging in: f(1)
debug: {
x
}
Browse[1]> Q
> g <- f
> g(1)
debugging in: g(1)
debug: {
x
}
Browse[1]> Q
> environment(g) <- new.env()
> g(1)
[1] 1
>
>
P.S. Here is just the input if you want to try it yourself by copying
and pasting into an R session:
f <- function(x) { x }
f(1)
debug(f)
f(1)
Q
environment(f) <- new.env()
f(1)
Q
g <- f
g(1)
Q
environment(g) <- new.env()
g(1)
_______________________________________________
Make My Way your home on the Web - http://www.myway.com
More information about the R-help
mailing list