r – Change value of variable with dplyr

r – Change value of variable with dplyr

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()

r – Change value of variable with dplyr

Leave a Reply

Your email address will not be published.