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
However, for rename_at() when no vars are returned (no columns are matched) an error is thrown.
mtcars %>% rename_at(vars(contains("fake_col")),~paste0("NewCol.",.))
#> Error: `nm` must be `NULL` or a character vector the same length as `x`
This might be the desired behavior (if so, I will close this issue). I was relying on the mutate_at() behavior with the implied conditional that if nothing matches vars(contains()) the piped sequence could continue with the unmodified tbl, and then I ran into trouble when I was counting on rename_at() to behave the same way.
The text was updated successfully, but these errors were encountered:
wkdavis
changed the title
Differing behavior when vars doesn't match any columns
Differing behavior when vars doesn't match any columns
Apr 9, 2019
In the case of select_at() it may be more intuitive to return an empty tbl (rather than .tbl unmodified), as you are effectively selecting no columns because none of the columns matched the .predicate. But after thinking about it for a moment, this might be unexpected considering that the behavior of mutate_at() (and now rename_at()) is to return an unmodified tbl upon not matching any .vars.
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/
lockbot
locked and limited conversation to collaborators
Nov 2, 2019
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
It appears that the behavior of
mutate_at()
andrename_at()
differs when no columns are returned usingvars()
andcontains()
.For
mutate_at()
, when no vars are returned (no columns are matched) it returns an unmodified tbl.However, for
rename_at()
when no vars are returned (no columns are matched) an error is thrown.This might be the desired behavior (if so, I will close this issue). I was relying on the
mutate_at()
behavior with the implied conditional that if nothing matchesvars(contains())
the piped sequence could continue with the unmodified tbl, and then I ran into trouble when I was counting onrename_at()
to behave the same way.The text was updated successfully, but these errors were encountered: