[R] Does R have a "const object"?
Gabor Grothendieck
ggrothendieck at gmail.com
Tue Mar 15 19:41:16 CET 2011
On Tue, Mar 15, 2011 at 10:53 AM, xiagao1982 <xiagao1982 at gmail.com> 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!
>
>
LockBinding will prevent a variable from being modified (but you could
still rm it and then subsequently create a variable of the same name).
> xx <- 33
> lockBinding("xx", .GlobalEnv)
> xx <- 44
Error: cannot change value of locked binding for 'xx'
> rm(xx) # can still do this
--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com
More information about the R-help
mailing list