Attribute order makes a difference in equality comparisons when atomic vectors are put in lists, but not when they're not. identical() does not exhibit this inconsistent behaviour. vctrs 0.6.5.
suppressPackageStartupMessages({
library(dplyr)
library(vctrs)
})
x <- structure(1L, foo = 1L, bar = "1L")
y <- structure(1L, bar = "1L", foo = 1L)
# vctrs thinks they're the same.
vec_equal(x, y)
#> [1] TRUE
# Unless we put them both in lists
vec_equal(list(x), list(y))
#> [1] FALSE
identical(list(x), list(y))
#> [1] TRUE
# The context I came across this: joining on list columns
df_x <- tibble(v1 = list(x))
df_y <- tibble(v1 = list(y))
identical(df_x, df_y)
#> [1] TRUE
vec_equal(df_x, df_y)
#> [1] FALSE
vec_locate_matches(df_x, df_y)
#> needles haystack
#> 1 1 NA
anti_join(df_x, df_y)
#> Joining with `by = join_by(v1)`
#> # A tibble: 1 × 1
#> v1
#> <list>
#> 1 <int [1]>
Created on 2025-06-26 with reprex v2.1.1