[R] all.equal and use.names

John Harrold john@m@h@rro|d @end|ng |rom gm@||@com
Thu May 28 05:22:56 CEST 2020


Howdy Folks,

I believe I'm having trouble understanding the documentation for all.equal.
If I have two lists like this:

t1 = list(a = c(1,2,3),
          b = c("1", "2", "3"))
t2 = list( b = c("1", "2", "3"),
           a = c(1,2,3))

If I read the documentation correctly, by setting use.names equal to TRUE I
believe this comparison should evaluate as true:

all.equal(t1,t2, use.names=TRUE)

However, I get the following output:

which appears as though it is performing the comparison based on walking
through indices and comparing that way.

[1] "Names: 2 string mismatches"
[2] "Component 1: Modes: numeric, character"
[3] "Component 1: target is numeric, current is character"
[4] "Component 2: Modes: character, numeric"
[5] "Component 2: target is character, current is numeric"

Can someone tell me what I'm doing wrong here?
-- 
John
:wq

	[[alternative HTML version deleted]]



More information about the R-help mailing list