[Rd] S4 slot with NA default

Vladimir Dergachev vdergachev at rcgardis.com
Wed Mar 26 17:23:56 CET 2008


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 is
> known, I  will create a new object with the correct value inserted in
> the slot.
>
> I want "NA" to signify "not known".
>
> My attempt fails because NA is not numeric:
>

Try as.numeric(NA) - by default, plain NA is of type "logical"

                  best

                    Vladimir Dergachev

>
>
>
> --
> Robin Hankin
> Uncertainty Analyst and Neutral Theorist,
> National Oceanography Centre, Southampton
> European Way, Southampton SO14 3ZH, UK
>   tel  023-8059-7743
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



-- 
Vladimir Dergachev            RCG Ardis Capital LLC



More information about the R-devel mailing list