On Tue, Mar 15, 2011 at 10:53 AM, xiagao1982 <xiagao1...@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 ______________________________________________ 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.