You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems like setequal compares column types while setdiff doesn't.
df1<-data.frame(x=1)
df2<-df1# df1$x and df2$x are both of type `num`
setdiff(df1, df2) # --> will output 0-rowed data.frame
setequal(df1, df2) # --> will output TRUEdf2$x %<>% as.integer# df1$x is of type `num` while df2$x is of type `int`
setdiff(df1, df2) # --> will output 0-rowed data.frame
setequal(df1, df2) # --> will output FALSE
I can see how this could actually be the intended behavior.
However, in that case a hint in the docs would be great.
The text was updated successfully, but these errors were encountered:
hadley
changed the title
setdiff vs. setequal when comparing dataframes/tibbles with different column type
setdiff vs. setequal inconsitency when columns have different types
Jul 22, 2022
I don't love that there's so much variation in where the casting happens in these functions, but this seems like the simplest fix. `covert = TRUE` here eventually calls `vec_ptype2(x_i, y_i)` so it's still using vctrs rules.
Fixes#6114.
* `setequal()` now coerces columns to common type. Fixes#6114.
* `setequal()` ignores duplicates. Fixes#6057.
* Reorganised code to emphasise similarities between functions.
* Refactored tests and increased coverage to 100%.
It seems like
setequal
compares column types whilesetdiff
doesn't.I can see how this could actually be the intended behavior.
However, in that case a hint in the docs would be great.
The text was updated successfully, but these errors were encountered: