Change value of variable with dplyr [duplicate] Change value of variable with dplyr [duplicate] r r

Change value of variable with dplyr [duplicate]


We can use replace to change the values in 'mpg' to NA that corresponds to cyl==4.

mtcars %>%     mutate(mpg=replace(mpg, cyl==4, NA)) %>%     as.data.frame()