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)

Arguments

.df

A data.frame or data.table

.predicate

predicate for mutate_if.() to use

.funs

Functions to pass. Can pass a list of functions.

...

Other arguments for the passed function

.by

Columns to group by

.vars

vector c() of bare column names for mutate_at.() to use

Examples

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
test_df %>% mutate_across.(c(x, y), ~ .x * 2)
#> # tidytable [3 × 3] #> x y z #> <dbl> <dbl> <chr> #> 1 2 4 a #> 2 2 4 a #> 3 2 4 b
test_df %>% mutate_across.(everything(), as.character)
#> # tidytable [3 × 3] #> x y z #> <chr> <chr> <chr> #> 1 1 2 a #> 2 1 2 a #> 3 1 2 b
test_df %>% mutate_across.(c(x, y), list(new = ~ .x * 2, another = ~ .x + 7))
#> # 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