Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

column renaming with dplyr

Tags:

r

dplyr

I am trying to rename a column using dplyr::rename, but failing..

library(dplyr)

cars %>% 
  filter(speed > 20) %>% 
  rename(speed = new_speed)

# Error: Unknown variables: new_speed.

Any ideas what's wrong there?

like image 469
Deena Avatar asked Oct 31 '25 02:10

Deena


1 Answers

It's the other way

cars %>% 
  filter(speed > 20) %>% 
  rename(new_speed = speed)
like image 199
CClaire Avatar answered Nov 02 '25 16:11

CClaire