[Rd] assignment
Gabor Grothendieck
ggrothend|eck @end|ng |rom gm@||@com
Mon Dec 27 14:33:57 CET 2021
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?
--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com
More information about the R-devel
mailing list