Several people have suggested as.numeric(NA). That evaluates to NA_real_,
so provided you don't want to support R < 2.5.0 it is (slightly) more
efficient in several ways to use NA_real_ .
On Wed, 26 Mar 2008, Roger Bivand wrote:
> On Wed, 26 Mar 2008, Robin Hankin wrote:
>
>> Hi
>>
>> How do I
Hi Robin,
you could try this:
> setClass("foo",
representation=representation(x="numeric"),prototype=list(x=as.numeric(NA)))
> test<-new("foo")
> test
>An object of class "foo"
>Slot "x":
>[1] NA
Cheers,
Christian
Robin Hankin wrote:
> Hi
>
> How do I specify an S4 class with a slot that is po
On Wed, 26 Mar 2008, Robin Hankin wrote:
> Hi
>
> How do I specify an S4 class with a slot that is potentially numeric,
> but NA
> by default? I want the slot to be NA until I calculate its value
> (an expensive operation, not needed for all applications). When
> its value is
> known, I wil
Robin Hankin wrote:
> Hi
>
> How do I specify an S4 class with a slot that is potentially numeric,
> but NA
> by default? I want the slot to be NA until I calculate its value
> (an expensive operation, not needed for all applications). When
> its value is
> known, I will create a new ob
On Mar 26, 2008, at 12:04 PM, Robin Hankin wrote:
> Hi
>
> How do I specify an S4 class with a slot that is potentially numeric,
> but NA
> by default? I want the slot to be NA until I calculate its value
> (an expensive operation, not needed for all applications). When
> its value is
> kno
On Wednesday 26 March 2008 12:04:11 pm Robin Hankin wrote:
> Hi
>
> How do I specify an S4 class with a slot that is potentially numeric,
> but NA
> by default? I want the slot to be NA until I calculate its value
> (an expensive operation, not needed for all applications). When
> its value
Hi
How do I specify an S4 class with a slot that is potentially numeric,
but NA
by default? I want the slot to be NA until I calculate its value
(an expensive operation, not needed for all applications). When
its value is
known, I will create a new object with the correct value inserte