From Robert.McGehee at geodecapital.com  Thu Jun 22 17:19:52 2006
From: Robert.McGehee at geodecapital.com (McGehee, Robert)
Date: Thu, 22 Jun 2006 11:19:52 -0400
Subject: [Rd] Suggestion for all.equal.factor
Message-ID: <67DCA285A2D7754280D3B8E88EB548020F8EF5AB@MSGBOSCLB2WIN.DMN1.FMR.COM>

Errata:
As Tony Plate pointed out to me, the patch I had meant to submit was
this:

if (length(nax) == length(nay) && (n <- sum(nax != nay)) 

as my previous patch simply assigned a TRUE or FALSE to n rather than
the count of NA mismatches.

Cheers,
Robert

-----Original Message-----
From: r-devel-bounces at r-project.org
[mailto:r-devel-bounces at r-project.org] On Behalf Of McGehee, Robert
Sent: Wednesday, June 21, 2006 7:13 PM
To: R-devel
Subject: [Rd] Suggestion for all.equal.factor

R-Devel,
all.equal.factor gives a warning message when comparing vectors of
factors of different lengths. I suspect this to be unintentional as I
believe tests of valid factors should be comparable without a warning.

For example:
> x1 <- as.factor(LETTERS)
> x2 <- as.factor(LETTERS)[1:10]
> all.equal.factor(x1, x2)
[1] "Lengths: 26, 10"

[2] "Lengths (26, 10) differ (string compare on first 10)"

Warning message:
longer object length
	is not a multiple of shorter object length in: nax != nay 

If it is not improper to compare objects of different lengths, I would
like to propose the following patch that removes this warning without
otherwise changing the behavior of all.factor.equal.

-     if(n <- sum(nax != nay))
+     if(n <- length(nax) == length(nay) && sum(nax != nay))

My assumption here is that it is not meaningful to compare NA mismatches
on vectors of different lengths. Also, if the vectors do have different
lengths then this will be reported in the first line anyway.

Best,
Robert

> R.version
               _                         
platform       i386-pc-mingw32           
arch           i386                      
os             mingw32                   
system         i386, mingw32             
status                                   
major          2                         
minor          3.1                       
year           2006                      
month          06                        
day            01                        
svn rev        38247                     
language       R                         
version.string Version 2.3.1 (2006-06-01)

Robert McGehee
Quantitative Analyst
Geode Capital Management, LLC
53 State Street, 5th Floor | Boston, MA | 02109
Tel: 617/392-8396    Fax:617/476-6389
mailto:robert.mcgehee at geodecapital.com



This e-mail, and any attachments hereto, are intended for
us...{{dropped}}

______________________________________________
R-devel at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] Suggestion for all.equal.factor
McGehee, Robert