patch: Conditional patching of data.frames

Description Usage Arguments Author(s) Examples

View source: R/patch.R

Description

Performs one or several 'mutate' on a data.frame, but only on rows matching the specified condition(s).

Usage

1
2
3
4
5
6
patch(object, cond, ...)

## S3 method for class 'data.frame'
patch(object, cond, ..., quiet = FALSE)

where(..., .follow_symbols = FALSE, .ignore_empty = FALSE)

Arguments

object

Data.frame to patch

cond

The condition(s) selecting the rows to patch. Should be wrapped in "where".

...

Action(s) to take, in the form 'var=new_value'.

quiet

If FALSE, a message indicating number of patched rows will be printed.

Author(s)

Antoine Sachet

Examples

1
2
3
4
5
6
7
8
patch(mtcars, where(vs == 0, am == 1), gear = Inf, carb = carb + 10)

## Not run: 
# Also setting corresponding related_var observations to NA
# Setting incorrect (negative) values in data$positive_var to NA
mydata %>% patch(where(positive_var<0), positive_var=NA, related_var=NA)

## End(Not run)

antoine-sachet/customFunctions documentation built on Sept. 25, 2020, 8:56 p.m.