Skip to content
Prev 389819 / 398503 Next

Environmental oddity.

I have two functions which appear to differ only in their environments.
They look like:
and
Typing "environment(d1)" gives
and typing "environment(d2)" gives
The d2() function however gives an incorrect result:
In d2() the result of the if() statement does not get divided
by the final "sd" whereas in d1() it does (which is the desired/correct
result).

Of course the code is ridiculously kludgy (it was produced by "symbolic
differentiation").  That's not the point.  I'm just curious (idly?) as
to *why* the association of the namespace:stats environment with d1()
causes it to "do the right thing".

Can anyone give me any insight?  Ta.

cheers,

Rolf Turner