On 16/03/11 15:04, Gabor Grothendieck wrote:
On Wed, Mar 16, 2011 at 10:54 AM, Allan Engelhardt<all...@cybaea.com>  wrote:
[...]
Yes, but you can still print(base::pi) and rm(pi) to get back to our flat
world, and you can't

assign("pi", 4, pos = "package:base")
Error in assign("pi", 4, pos = "package:base") :
  cannot change value of locked binding for 'pi'

Just a feature of the search path.  Morale: if you want base::pi, write
base::pi.

Try this:

old.pi<- pi
assignInNamespace("pi", 2.3, ns = "base")
pi
[1] 2.3
base::pi
[1] 2.3

Ah! assignInNamespace does an unlockBinding under the covers which obviously is Evil(tm). The answer clearly is to do

assignInNamespace("unlockBinding", function (...) {warning("be safe");}, ns="base")

in your .Rprofile!  Let's Keep R Safe, Folks!

Allan

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to