Re: [R] Does R have a "const object"?

From: Allan Kamau <kamauallan_at_gmail.com>
Date: Wed, 16 Mar 2011 14:24:58 +0300

On Wed, Mar 16, 2011 at 6:47 AM, Thomas Lumley <tlumley_at_uw.edu> wrote:
> Actually, you can do this using locked bindings.  Look at ?lockBinding
>
> Locked bindings are how namespaces get const function definitions, and
> active bindings (on the same help page) are how R CMD check notices
> that you are using T and F when you mean TRUE and FALSE.
>
>   -thomas
>
>
> On Wed, Mar 16, 2011 at 1:52 PM,  <rex.dwyer_at_syngenta.com> wrote:
>> Cheer up! R is a step closer to that concept than the old FORTRAN compilers that couldn't even guarantee that 37 was a constant if used repeatedly in a subroutine call.
>>
>> -----Original Message-----
>> From: r-help-bounces_at_r-project.org [mailto:r-help-bounces_at_r-project.org] On Behalf Of Uwe Ligges
>> Sent: Tuesday, March 15, 2011 2:23 PM
>> To: xiagao1982
>> Cc: r-help
>> Subject: Re: [R] Does R have a "const object"?
>>
>>
>>
>> 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".
>>
>> Best,
>> Uwe  Ligges
>>
>>
>>>
>>>
>>>
>>> xiagao1982
>>> 2011-03-15
>>>
>>>       [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> R-help_at_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.
>>
>> ______________________________________________
>> R-help_at_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.
>>
>>
>>
>>
>> message may contain confidential information. If you are not the designated recipient, please notify the sender immediately, and delete the original and any copies. Any use of the message by you is prohibited.
>> ______________________________________________
>> R-help_at_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.
>>
>
>
>
> --
> Thomas Lumley
> Professor of Biostatistics
> University of Auckland
>
> ______________________________________________
> R-help_at_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.
>

Perhaps a crude alternative is to place the value in some file perhaps manually and set the file permissions to disallow writing but allow reading. Then you can then always read the value from this file during your programs execution.

Allan.



R-help_at_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. Received on Wed 16 Mar 2011 - 11:31:00 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 16 Mar 2011 - 12:10:23 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive