[Rd] [External] Re: 1954 from NA

Adrian Dușa du@@@@dr|@n @end|ng |rom gm@||@com
Wed May 26 16:22:36 CEST 2021


Dear Duncan,

On Wed, May 26, 2021 at 2:27 AM Duncan Murdoch <murdoch.duncan using gmail.com>
wrote:

> You've already been told how to solve this:  just add attributes to the
> objects. Use the standard NA to indicate that there is some kind of
> missingness, and the attribute to describe exactly what it is.  Stick a
> class on those objects and define methods so that subsetting and
> arithmetic preserves the extra info you've added. If you do some
> operation that turns those NAs into NaNs, big deal:  the attribute will
> still be there, and is.na(NaN) still returns TRUE.
>

I've already tried the attributes way, it is not so easy.
In the best case scenario, it unnecessarily triples the size of the data,
but perhaps this is the only way forward.



> Base R doesn't need anything else.
>
> You complained that users shouldn't need to know about attributes, and
> they won't:  you, as the author of the package that does this, will
> handle all those details.  Working in your subject area you know all the
> different kinds of NAs that people care about, and how they code them in
> input data, so you can make it all totally transparent.  If you do it
> well, someone in some other subject area with a completely different set
> of kinds of missingness will be able to adapt your code to their use.
>

But that is the whole point: the package author does not define possible
NAs (the possibilities are infinite), users do that.
The package should only provide a simple method to achieve that.


I imagine this has all been done in one of the thousands of packages on
> CRAN, but if it hasn't been done well enough for you, do it better.
>

If it were, I would have found it by now...

Best wishes,
Adrian

	[[alternative HTML version deleted]]



More information about the R-devel mailing list