Function 'tapply' in R devel r72137 uses
if(!is.null(ans) && is.na(default) && is.atomic(ans)) .

Problems:
- It is possible that user-specified 'default' is not of length 1. If the 
length is zero, the 'if' gives an error.
- It is possible that is.na(default) is TRUE and user-specified 'default' is 
NaN.

--------------------------------------------
On Sat, 4/2/17, Martin Maechler <maech...@stat.math.ethz.ch> wrote:

 Subject: Re: [Rd] RFC: tapply(*, ..., init.value = NA)

 Cc: R-devel@r-project.org
 Date: Saturday, 4 February, 2017, 10:48 PM
 
>>>>> Suharto Anggono Suharto Anggono via R-devel <r-devel at r-project.org>
>>>>>     on Wed, 1 Feb 2017 16:17:06 +0000 writes:

[snip]

    > vector(typeof(ans)) (or vector(storage.mode(ans))) has
    > length zero and can be used to initialize array.  

Yes,.. unless in the case where ans is NULL.
You have convinced me, that is  nicer.

    > Instead of if(missing(default)) , if(identical(default,
    > NA)) could be used. The documentation could then say, for
    > example: "If default = NA (the default), NA of appropriate
    > storage mode (0 for raw) is automatically used."

After some thought (and experiments), I have reverted and no
longer use if(missing). You are right that it is not needed
(and even potentially confusing) here.

Changes are in svn c72106.

Martin Maechler

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to