On Wed, Mar 16, 2011 at 10:54 AM, Allan Engelhardt <all...@cybaea.com> wrote: > > > On 16/03/11 13:04, Michael Friendly wrote: >> >> On 3/15/2011 2:23 PM, Uwe Ligges wrote: >>> >>> >>> On 15.03.2011 15:53, xiagao1982 wrote: >>>> >>>> Hi, all, >>>> >>>> Does R have a "const object" concept like which is in C++ language? I >>>> want to set some data frames as constant to avoid being modified >>>> unintentionally. Thanks! >>> >>> >>> Although there is almost never a "No" in R, the best short answer is: >>> "No". >> >> This is just the flexibility of R. I've just discovered a new class of >> geometries based on >> >> > pi <- 2.3 >> ?Constants > > 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 -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com ______________________________________________ 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.