Closed sebffischer closed 1 year ago
A more general question: What is the intended behaviour if x
or y
have duplicated values? I'm a bit confused by the comment
# now this is checkSetEqual(..., ordered = TRUE) with additional sorting.
Also, x != y
will not work with missing values.
Edit: Well, at least not in all cases, e.g. any(c(FALSE,NA) != c(FALSE, NA))
Duplicated values are not treated special in any way or what exactly do you mean by that?
I think the comment regarding the checkSetEqual with ordered = TRUE is actually incorrect and should be removed. What I mean by that is that comparing [1, 2, 1] with [1, 1, 2] essentially turns into checking whether all [1, 1, 2] == [1, 1, 2]. This also shows how the duplicated values are being handled.
Yes, but the x != y
never contains missing values (they are dropped by the sort, see the comment).
Sorting comes after the length check, so this fails?
x = c(1, NA)
y = c(1)
Yes. Note that we check the length twice.
Your example is captured in the first length check
Edit: I mean "Yes, this returns FALSE"
Ok, got it now. I think you could clarify a bit in the documentation, but otherwise good to be merged.
I added some comments
@mllg
Can this be merged @mllg ?
The only thing I am unhappy with is the
any(x != y)
, there should be a faster way to test this. Any suggestions? But I could not quickly find a function that does that. At least identical might be tricky with factors. Maybe some version of all.equal?