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
I thought I could use map over a list of data frames to rename them using rename_with() and a tidyselector like matches(), whether or not each data frame has a matching column name. Now it looks as though that is not longer possible (#6688).
That's all fine and good. Now I see I can just use rename(), which does not error. But I think the error for rename_with() could be more clear by saying that there is no match.
Lastly, I'm curious: why the difference in erroring vs. not between rename() and rename_with()?
It isn't really the fact that there is no match in matches("qwerty") that is the problem. That's totally fine. It's the fact that you matched 0 column names (i.e. the input to your .fn) but the output has length 1 ("joe").
rename_with() isn't really meant to be used with a static result like that, it is more often used where you take the input, apply some transformation, and return some output of the same size, like .fn = ~ stringr::str_c("blah.", .x).
So I think it is probably just the wrong function for what you were trying to do
I thought I could use map over a list of data frames to rename them using
rename_with()
and a tidyselector likematches()
, whether or not each data frame has a matching column name. Now it looks as though that is not longer possible (#6688).That's all fine and good. Now I see I can just use
rename()
, which does not error. But I think the error forrename_with()
could be more clear by saying that there is no match.Lastly, I'm curious: why the difference in erroring vs. not between
rename()
andrename_with()
?Created on 2023-10-26 with reprex v2.0.2
The text was updated successfully, but these errors were encountered: