[Rd] duplicated fails to rise correct errors (PR#13632)

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Mon Mar 30 15:18:25 CEST 2009


the bug seems to have a trivial solution;  as far as i can see, it suffices to 
replace

    if (!is.logical(incomparables) || incomparables)

with

    if(!identical(incomparables, FALSE))

in all its occurrences in src/library/base/R/duplicated.R

attached is a patch created, successfully tested and installed on Ubuntu 8.04 
Linux 32 bit as follows:

    svn co https://svn.r-project.org/R/trunk trunk
    cd trunk
    # edit src/library/base/R/duplicated.R
    svn diff > duplicated.R.diff

    svn revert -R src
    patch -p0 < duplicated.R.diff
    tools/rsync-recommended
    ./configure
    make
    make check

and now

    duplicated(data.frame(), incomparables=NA)
    # error: argument 'incomparables != FALSE' is not used (yet)

regards,
vQ



Waclaw.Marcin.Kusnierczyk at idi.ntnu.no wrote:
> Full_Name: Wacek Kusnierczyk
> Version: 2.8.0 and 2.10.0 r48242
> OS: Ubuntu 8.04 Linux 32 bit
> Submission from: (NULL) (129.241.110.161)
>
>
> In the following code:
>
>    duplicated(data.frame(), incomparables=NA)
>    # Error in if (!is.logical(incomparables) || incomparables)
> .NotYetUsed("incomparables != FALSE") : 
>    # missing value where TRUE/FALSE needed
>
> the raised error is clearly not the one intended to be raised.
>
> ?duplicated says:
>
> "
> incomparables: a vector of values that cannot be compared. 'FALSE' is a
>           special value, meaning that all values can be compared, and
>           may be the only value accepted for methods other than the
>           default.  It will be coerced internally to the same type as
>           'x'.
>
> (...)
>
>      Values in 'incomparables' will never be marked as duplicated. This
>      is intended to be used for a fairly small set of values and will
>      not be efficient for a very large set.
> "
>
> However, in duplicated.data.frame (which is called when duplicated is applied to
> a data frame, as above) the parameter 'incomparables' is defunct.  The
> documentation fails to explain this, and it might be a good idea to improve it.
>
> In the code for duplicated.data.frame there is an attempt to intercept any use
> of the parameter 'incomparables' with a value other than FALSE and to raise an
> appropriate error, but this attempt fails with, e.g., incomparables=NA.
>
> Incidentally, the attempt to intercept incomparables != FALSE fails completely
> (i.e., the call to duplicated succeeds) with certain inputs:
>
>    duplicated(data.frame(logical=c(TRUE, TRUE)), incomparables=c(FALSE, TRUE))
>    # [1] FALSE TRUE
>
> while
>
>    duplicated(c(TRUE, TRUE), incomparables=c(FALSE, TRUE))
>    # [1] FALSE FALSE
>
>
> Regards,
> vQ
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>   


-- 
-------------------------------------------------------------------------------
Wacek Kusnierczyk, MD PhD

Email: waku at idi.ntnu.no
Phone: +47 73591875, +47 72574609

Department of Computer and Information Science (IDI)
Faculty of Information Technology, Mathematics and Electrical Engineering (IME)
Norwegian University of Science and Technology (NTNU)
Sem Saelands vei 7, 7491 Trondheim, Norway
Room itv303

Bioinformatics & Gene Regulation Group
Department of Cancer Research and Molecular Medicine (IKM)
Faculty of Medicine (DMF)
Norwegian University of Science and Technology (NTNU)
Laboratory Center, Erling Skjalgsons gt. 1, 7030 Trondheim, Norway
Room 231.05.060

-------------------------------------------------------------------------------

-------------- next part --------------
A non-text attachment was scrubbed...
Name: duplicated.R.diff
Type: text/x-diff
Size: 1536 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-devel/attachments/20090330/c2595605/attachment.bin>


More information about the R-devel mailing list