Bug 14742 - duplicated.data.frame ignores fromLast if x has only one column
duplicated.data.frame ignores fromLast if x has only one column
Status: CLOSED FIXED
Product: R
Classification: Unclassified
Component: Language
R 2.14.0
All Mac OS X v10.6
: P5 normal
Assigned To: R-core
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-12-01 15:10 UTC by Tim Bergsma
Modified: 2011-12-04 22:47 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Bergsma 2011-12-01 15:10:28 UTC
Compare:
> duplicated(data.frame(c(1,1)))
[1] FALSE  TRUE
> duplicated(data.frame(c(1,1)),fromLast=TRUE)
[1] FALSE  TRUE
> duplicated(c(1,1),fromLast=TRUE)
[1]  TRUE FALSE

From the documentation, it would be reasonable to expect the second call to behave like the third, not the first.  In the method, fromLast is not forwarded in the case that length(x)==1.  Probably it should be, or if there is good reason not to do so, this should be documented. 

> duplicated.data.frame
function (x, incomparables = FALSE, fromLast = FALSE, ...) 
{
    if (!identical(incomparables, FALSE)) 
        .NotYetUsed("incomparables != FALSE")
    if (length(x) != 1L) 
        duplicated(do.call("paste", c(x, sep = "\r")), fromLast = fromLast)
    else duplicated(x[[1L]])
}
<bytecode: 0x103c72180>
<environment: namespace:base>