From suharto_anggono at yahoo.com  Tue Feb  7 16:56:24 2017
From: suharto_anggono at yahoo.com (Suharto Anggono Suharto Anggono)
Date: Tue, 7 Feb 2017 15:56:24 +0000 (UTC)
Subject: [Rd] RFC: tapply(*, ..., init.value = NA)
References: <237959543.2771616.1486482984670.ref@mail.yahoo.com>
Message-ID: <237959543.2771616.1486482984670@mail.yahoo.com>

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 <maechler at stat.math.ethz.ch> wrote:

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

 Cc: R-devel at 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



[Rd] RFC: tapply(*, ..., init.value = NA)
Suharto Anggono Suharto Anggono