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

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to