Re: [Rd] S4 slot with NA default

2008-03-26 Thread Prof Brian Ripley
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

Re: [Rd] S4 slot with NA default

2008-03-26 Thread Christian Kohler
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

Re: [Rd] S4 slot with NA default

2008-03-26 Thread Roger Bivand
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

Re: [Rd] S4 slot with NA default

2008-03-26 Thread Peter Dalgaard
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

Re: [Rd] S4 slot with NA default

2008-03-26 Thread Simon Urbanek
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

Re: [Rd] S4 slot with NA default

2008-03-26 Thread Vladimir Dergachev
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

[Rd] S4 slot with NA default

2008-03-26 Thread Robin Hankin
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