On Mon, 27 Dec 2021, Gabor Grothendieck wrote:
In a recent SO post this came up (changed example to simplify it
here). It seems that `test` still has the value sin.
test <- sin
environment(test)$test <- cos
test(0)
## [1] 0
It appears to be related to the double use of `test` in `$<-` since if
we break it up it works as expected:
test <- sin
e <- environment(test)
e$test <- cos
test(0)
## [1] 1
`assign` also works:
test <- sin
assign("test", cos, environment(test))
test(0)
## [1] 1
Can anyone shed some light on this?
See my response in
https://bugs.r-project.org/show_bug.cgi?id=18269
Best,
luke
--
Luke Tierney
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa Phone: 319-335-3386
Department of Statistics and Fax: 319-335-3017
Actuarial Science
241 Schaeffer Hall email: luke-tier...@uiowa.edu
Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel