Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to let identical ignore attribute/names?

Tags:

r

> str(a)
 Named int [1:5] 0 0 0 0 0
 - attr(*, "names")= chr [1:5] "Var2" "Var3" "Var4" "Var5" ...
> str(b)
 Named int [1:5] 0 0 0 0 0
 - attr(*, "names")= chr [1:5] "Var1" "Var2" "Var3" "Var4" ...
> identical(a,b)
[1] FALSE

I realized that identical compare not only the vectors content, but the names as well.

How to avoid the names check without manually deleting them?

like image 780
colinfang Avatar asked Oct 25 '25 01:10

colinfang


1 Answers

This gives the desired result:

> identical( unname(a), unname(b))
[1] TRUE

This gives a useful result but misleading information:

> mapply("==", a ,b)
Var2 Var3 Var4 Var5 Var6 
TRUE TRUE TRUE TRUE TRUE 
like image 124
IRTFM Avatar answered Oct 27 '25 16:10

IRTFM