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.

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