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

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 Nov. 17, 2017, 7:34 a.m.