描述

    replace_na_dt可以将所有NAs替换为另一个值,而replace_dt可以将任何值替换为另一个特定的值。

    Usage

    replace_dt(.data, …, from = is.nan, to = NA)

    1. iris %>% mutate_vars(is.factor,as.character) -> new_iris
    2. new_iris %>%
    3. replace_dt(Species, from = "setosa",to = "SS")
    4. new_iris %>%
    5. replace_dt(Species,from = c("setosa","virginica"),to = "sv")
    6. new_iris %>%
    7. replace_dt(Petal.Width, from = .2,to = 2)
    8. new_iris %>%
    9. replace_dt(from = .2,to = NA)
    10. new_iris %>%
    11. replace_dt(is.numeric, from = function(x) x > 3, to = 9999 )