iris %>% as.data.table() %>%
mutate(Species = as.character(Species))-> new_iris
new_iris %>%
replace_vars(Species, from = "setosa",to = "SS")
new_iris %>%
replace_vars(Species,from = c("setosa","virginica"),to = "sv")
new_iris %>%
replace_vars(Petal.Width, from = .2,to = 2)
new_iris %>%
replace_vars(from = .2,to = NA)
new_iris %>%
replace_vars(is.numeric, from = function(x) x > 3, to = 9999 )
Run the code above in your browser using DataLab