Learn R Programming

tidytable (version 0.5.8)

mutate_if.: Deprecated mutate helpers

Description

These helpers have been deprecated. Please use mutate_across.()

Usage

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

Run this code
# NOT RUN {
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)

test_df %>%
  mutate_across.(c(x, y), ~ .x * 2)

test_df %>%
  mutate_across.(everything(), as.character)

test_df %>%
  mutate_across.(c(x, y), list(new = ~ .x * 2,
                               another = ~ .x + 7))
# }

Run the code above in your browser using DataLab