These helpers have been deprecated. Please use mutate_across.()
mutate_if.(.df, .predicate, .funs, ..., .by = NULL) mutate_at.(.df, .vars, .funs, ..., .by = NULL) mutate_all.(.df, .funs, ..., .by = NULL)
.df | A data.frame or data.table |
---|---|
.predicate | predicate for |
.funs | Functions to pass. Can pass a list of functions. |
... | Other arguments for the passed function |
.by | Columns to group by |
.vars | vector |
test_df <- data.table( x = c(1,1,1), y = c(2,2,2), z = c("a", "a", "b")) test_df %>% mutate_across.(where(is.numeric), as.character)#> # tidytable [3 × 3] #> x y z #> <chr> <chr> <chr> #> 1 1 2 a #> 2 1 2 a #> 3 1 2 b#> # tidytable [3 × 3] #> x y z #> <dbl> <dbl> <chr> #> 1 2 4 a #> 2 2 4 a #> 3 2 4 b#> # tidytable [3 × 3] #> x y z #> <chr> <chr> <chr> #> 1 1 2 a #> 2 1 2 a #> 3 1 2 b#> # tidytable [3 × 7] #> x y z x_new y_new x_another y_another #> <dbl> <dbl> <chr> <dbl> <dbl> <dbl> <dbl> #> 1 1 2 a 2 4 8 9 #> 2 1 2 a 2 4 8 9 #> 3 1 2 b 2 4 8 9