I regularly need to change the values ββof a variable based on the values ββfor another variable, for example:
mtcars$mpg[mtcars$cyl == 4] <- NA
I tried to do this with dplyr , but failed:
mtcars %>% mutate(mpg = mpg == NA[cyl == 4]) %>% as.data.frame()
How can I do this with dplyr ?
r dataframe dplyr plyr
luciano Jan 18 '15 at 7:28 2015-01-18 19:28
source share