Learn R Programming

lplyr (version 0.1.6)

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

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

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.

See Also

mutate, mutate_, transmute, transmute_ from package dplyr.

Examples

Run this code
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)

Run the code above in your browser using DataLab