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'm trying to use case_when() in a function used with rename_all(). In the simple example below, I have a renaming function applied to the mtcars dataset which should return "fuel_efficiency" for column names equal to "mpg" and otherwise return the original column name.
# Using dplyr 0.8.2 ----## Install current CRAN version 0.8.2
install.packages('dplyr')
#> Installing package into 'C:/Users/Ben Schneider/Documents/R/win-library/3.6'#> (as 'lib' is unspecified)#> package 'dplyr' successfully unpacked and MD5 sums checked#> #> The downloaded binary packages are in#> C:\Users\Ben Schneider\AppData\Local\Temp\Rtmp2VU53r\downloaded_packages## Run example
library(dplyr)
#> #> Attaching package: 'dplyr'#> The following objects are masked from 'package:stats':#> #> filter, lag#> The following objects are masked from 'package:base':#> #> intersect, setdiff, setequal, unionmtcars<-tibble::as_tibble(mtcars)
rename_all(mtcars,
function(x) case_when(x=='mpg'~'fuel_efficiency',
TRUE~x))
#> must have class `character`, not class `dplyr_sel_vars/character`
I'm trying to use
case_when()
in a function used withrename_all()
. In the simple example below, I have a renaming function applied to themtcars
dataset which should return"fuel_efficiency"
for column names equal to"mpg"
and otherwise return the original column name.With the latest
dplyr
release (0.8.2) this code no longer works and throws an error which I can't yet decipher.Below are the reprexes of this code used with
dplyr
0.8.1 anddplyr
0.8.2.From the news file and recent Github issues, I can't see why this would have stopped working. What's going on here?
Using
dplyr
0.8.1Created on 2019-07-02 by the reprex package (v0.3.0)
Session info
Using
dplyr
0.8.2Created on 2019-07-02 by the reprex package (v0.3.0)
Session info
The text was updated successfully, but these errors were encountered: