From a296180@agate.fmr.com  Wed Jul 10 13:52:17 2002
From: a296180@agate.fmr.com (a296180@agate.fmr.com)
Date: Wed, 10 Jul 2002 14:52:17 +0200 (MET DST)
Subject: bug in all.equal.character (PR#1767)
Message-ID: <200207101252.OAA13802@pubhealth.ku.dk>

There is a bug in all.equal.character:

> all.equal.character(c("A", "B", "C"), c("A", "B", "C"))
[1] TRUE
> all.equal.character(c("A", "B", "C"), c("A", "B", NA))
Error in sum(out) : Object "out" not found
> traceback()
3: sum(out)
2: paste("`is.NA' value mismatches:", sum(is.na(current)), "in current,", 
       sum(out), " in target")
1: all.equal.character(c("A", "B", "C"), c("A", "B", NA))
> 

It appears that there is a typo in all.equal.character. "out" is never created.

> all.equal.character
function (target, current, ...) 
{
    lt <- length(target)
    lc <- length(current)
    if (lt != lc) {
        msg <- paste("Lengths (", lt, ", ", lc, ") differ (string compare on first ", 
            ll <- min(lt, lc), ")", sep = "")
        ll <- seq(length = ll)
        target <- target[ll]
        current <- current[ll]
    }
    else msg <- NULL
    nas <- is.na(target)
    if (any(nas != is.na(current))) 
        return(paste("`is.NA' value mismatches:", sum(is.na(current)), 
            "in current,", sum(out), " in target"))
    ne <- !nas & (target != current)
    if (!any(ne) && is.null(msg)) 
        TRUE
    else if (any(ne)) 
        c(msg, paste(sum(ne), "string mismatches"))
    else msg
}
> 

Perhaps "sum(out)" should be "sum(is.na(target))"? That change would lead to:

> all.equal.character(c("A", "B", "C"), c("A", "B", NA))
[1] "`is.NA' value mismatches: 1 in current, 0  in target"
> 


> R.version
         _                   
platform sparc-sun-solaris2.6
arch     sparc               
os       solaris2.6          
system   sparc, solaris2.6   
status                       
major    1                   
minor    5.1                 
year     2002                
month    06                  
day      17                  
language R                   
> 

Apologies if this is a mistake on my part.

Regards,

Dave Kane


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


bug in all.equal.character (PR#1767)
a296180@agate.fmr.com