mutate_which: Add new variables or modify existing ones on a subset of the...

Description Usage Arguments Value Author(s) See Also Examples

View source: R/mutate_which.R

Description

The functions mutate_which and transmute_which are similar to mutate and transmute from package dplyr, except that they work only on a subset of .data, this subset being defined by the .condition.

The functions mutate_which_ and transmute_which_ are standard evaluation versions, similar to mutate_ and transmute_.

Usage

1
2
3
4
5
6
7
mutate_which(.data, .condition, ...)

mutate_which_(.data, .condition, ..., .dots)

transmute_which(.data, .condition, ...)

transmute_which_(.data, .condition, ..., .dots)

Arguments

.data

A tbl or data.frame.

.condition

A condition defining the subset on which the mutate or transmute operation applies. New variables are initialized to NA.

...

Name-value pairs of expressions. Use NULL to drop a variable.

.dots

Used to work around non-standard evaluation.

Value

A tbl or a data frame, depending on the class of .data.

Author(s)

Adapted from G. Grothendieck on StackOverflow, see http://stackoverflow.com/a/34096575.

See Also

mutate, mutate_, transmute, transmute_ from package dplyr.

Examples

1
2
3
4
5
6
7
8
9
df <- mtcars[1:10,]

# Non-standard evaluation
mutate_which(df, gear==4, carb = 100)
transmute_which(df, gear==4, carb = 100)

# Standard evaluation
mutate_which_(df, ~ gear==4, carb = ~ 100)
transmute_which_(df, ~ gear==4, carb = ~ 100)

lplyr documentation built on May 2, 2019, 11:58 a.m.