mutate_cond: mutate_cond

View source: R/util.R

mutate_condR Documentation

mutate_cond

Description

Execute dplyr mutate only for rows satisfying condition

Usage

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

Arguments

.data

A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr)

condition

condition for

...

<data-masking> Name-value pairs. The name gives the name of the column in the output.

envir

environment default( parent.frame())

Author(s)

ken4rab

Examples

library(dplyr)
df <- data.frame(a = c("X", "Y"), b = 0)
df <- df %>% mutate_cond(a == "X", b = 1)
df

rOpenStats/ElectionsLATAM documentation built on April 22, 2022, 12:53 a.m.