relocate.data.frame()
shouldn't rely on vec_unique()
retaining names
#6209
Labels
relocate.data.frame()
shouldn't rely on vec_unique()
retaining names
#6209
Currently,
relocate()
relies on the fact thatvec_unique()
keeps namesdplyr/R/relocate.R
Lines 83 to 85 in 8abb54b
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 withunique()
). 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 thenvec_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.
The text was updated successfully, but these errors were encountered: