-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Currently, relocate() relies on the fact that vec_unique() keeps names
Lines 83 to 85 in 8abb54b
| pos <- vec_unique(c(lhs, to_move, rhs)) | |
| out <- .data[pos] | |
| new_names <- names(pos) |
We think we should actually drop names from the result of vec_unique(), since the returned names are reliant on the fact that only the first encountered duplicate value is returned (this is also consistent with unique()). See r-lib/vctrs#1442 and r-lib/vctrs#1532 where we tried to implement this, but found that dplyr relies on this behavior currently.
One easy way to fix this is to use vec_unique_loc() to get the locations, and then vec_slice(), which will retain names.
That should work in the immediate term but it may be worth looking at the code to also see why we currently get names off the unique values, and if there is something else we should be doing instead, since that feels unreliable.