value_swap.data.frame: Swaps values on two variables on a dataframe.

Description Usage Arguments Examples

View source: R/value_swap.R

Description

Swaps values of two variables on a dataframe. Takes an optional index.

Usage

1
2
## S3 method for class 'data.frame'
value_swap(x, .svp, .swp, .idx = NULL, ...)

Arguments

x

A dataframe.

.svp

The name of the first variable involved in the value swap.

.swp

The name of the second variable involved in the value swap.

.idx

An optional row index. If ommitted all values are swapped between variables.

...

Arguments passed on to other methods.

Examples

1
2
3
4
5
6
7
df <- data.frame(a=c(1, 2),
                 b=c(3, 4),
                 c=c(4, 6))

index <- c(TRUE, FALSE)

value_swap(df, "a", "b", index)

aotearoastats/datacleanr documentation built on May 6, 2019, 9:49 p.m.