Skip to content

all.equal.list() sometimes fails with unnamed and named components (PR#674)

2 messages · Kurt Hornik, Peter Dalgaard

#
I think the above happens because all.equal.list() is broken.  The fix
is not entirely clear, because I am not sure what we really want.

Anyway, in all of the above examples we compare lists which are named in
the sense that names() is not NULL, but not ``fully'' named in the sense
that any(nchar(names()) == NULL) is TRUE.  In this case, iseq gets set
to nt[c.in.t] which in the above example gives

Browse[1]> nt[c.in.t]
[1] ""    ""    ""    "zap"

Hence in the for(i in iseq) loop we do three comparisons of the first
component, due to subscripting with "".

The obvious idea is that we must use positional indices where we do not
have named ones.

Now for the problem I see in the current logic.  We currently do

   if both lists are named (at least partially) then ... else fi

Maybe we should change this as follows: if either of the two lists has
names, work though the named components.  Warn about the ones not
present in both.  Compare the ones present in both.  Then get rid of all
named components and compare what is left in positional order.

As I said, I am not sure that this is really what we want.

Comments?

-k
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at> writes:
I think you might be right, and also that this is an easy thing to
implement. Then we'd have

all.equal(list(a=1,b=2,3,4),list(3,b=2,4,a=1)) == TRUE

Right?

However, BigBrother has
[1] "Names: 2 string mismatches"
attr(, "continue"):
[1] T
[1] T

..which does look like a "compatible bug"

Hmm. Maybe one wants positional matching in any case? But then, what
is the named-component extraction about??