Skip to contents

mutate_cond Change values in a tibble if some condition is fulfilled. Credits: https://stackoverflow.com/questions/34096162/dplyr-mutate-replace-several-columns-on-a-subset-of-rows.

Usage

mutate_cond(.data, condition, ..., envir = parent.frame())

Arguments

.data

Data frame / tibble

condition

A condition that need to be fulfilled.

...

The change that need to happen if condition fulfilled – through the use of `dplyr::mutate()`

envir

parent.frame() by default

Value

A tibble

Examples

if (FALSE) { # \dontrun{
mutate_cond(df, a == 3, b = 4)
} # }