Bug 14742

Summary: duplicated.data.frame ignores fromLast if x has only one column
Product: R Reporter: Tim Bergsma <timb>
Component: LanguageAssignee: R-core <R-core>
Status: CLOSED FIXED    
Severity: normal    
Priority: P5    
Version: R 2.14.0   
Hardware: All   
OS: Mac OS X v10.6   

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>