Use tidyselect::eval_select(allow_positional = FALSE)
for id_cols
when possible
#1541
Labels
tidyselect::eval_select(allow_positional = FALSE)
for id_cols
when possible
#1541
In going through some old code that I hadn't touched in a while, I found that
pivot_wider
was not working and was giving me the following error:Digging deeper, I think I've sorted out the overarching timing of the issue, and it is due to changes made between
tidyr
1.1.4 and 1.2.0 that changes the behavior, and between versions 1.2.1 and 1.3.0 where the error message changed to the above. I've included a reprex below that shows behavior in ver 1.1.4 and 1.3.1:Created on 2024-02-15 with reprex v2.1.0
A workaround is to use the column names in the
id_cols
argument; however, given older versions of thepivot_wider
function allowed the use of column numbers and there is an increased potential for error when entering names, it would be nice ifpivot_wider
functioned like it did intidyr
1.1.4 and before. I would also advocate for a return to the more descriptive error message when choosing variables that don't exist if that is possible, and including a descriptive warning/error if one attempts to choose a variable that is included in thenames_from
orvalues_from
arguments.If the removal of straightforward selection by column number is a feature and not a bug, I would request an update for the help and vignette to make this even clearer.
The text was updated successfully, but these errors were encountered: