Skip to content

all.equal and names?

5 messages · Spencer Graves, Duncan Murdoch, Marc Schwartz

#
How can I compare two objects for structure, names, values, etc.?  
With R 1.9.1 under Windows 2000, the obvious choice "all.equal" ignores 
names and compares only values: 

 > all.equal(1, c(a=1))
[1] TRUE

      Under S-Plus 6.2, I get the comparison I expected: 

 > all.equal(1, c(a = 1))
[1] "target, current classes differ: integer : 
named"                                                   
[2] "class of target is \"integer\", class of current is \"named\" 
(coercing current to class of target)"

      Thanks,
      Spencer Graves
#
On Wed, 18 Aug 2004 10:27:49 -0400, Spencer Graves
<spencer.graves at pdf.com> wrote :
If you want the explanation you're out of luck, but identical() does
the test:
[1] FALSE

Duncan Murdoch
#
Hi, Duncan: 

      Thanks much.  I think I remember reading about both "all.equal" 
and "identical" in Venables and Ripley (2002) MASS.  Unfortunately, I 
don't have MASS handy now, and I could not find it otherwise, so I asked. 

      What needs to happen to upgrade the "all.equal" documentation to 
add "identical" to the "see also"? 

      Best Wishes,
      Spencer
Duncan Murdoch wrote:

            
#
It is in the Description now (at least for 1.9.1 patched):

all.equal(x,y) is a utility to compare R objects x and y testing `near
equality'. If they are different, comparison is still made to some
extent, and a report of the differences is returned. Don't use all.equal
directly in if expressionsâ"either use identical or combine the two, as
shown in the documentation for identical.

There is also a reference to:

attr.all.equal(target, current, ...)

on the same help page, which returns the following using the example:
[1] "names for current but not for target"

Not quite the same message as S-PLUS however.

HTH,

Marc
On Wed, 2004-08-18 at 11:02, Spencer Graves wrote:
#
On Wed, 18 Aug 2004 12:02:02 -0400, Spencer Graves
<spencer.graves at pdf.com> wrote:

            
I just did it.  It was there in the text, but should also have been in
see-also.

In general to get something added to the docs, the best way is to
collect a few similar things, classify them as doc errors, suggested
improvements, etc, and post them to R-devel (if you're not sure
they'll be accepted) or to R-bugs (if they are sure things).  It's
definitely best to submit suggested replacement text.

Duncan Murdoch