replace_variable: Replaces a variable in the dataframe.

Description Usage Arguments Value Author(s) Examples

View source: R/replace_variable.R

Description

Replaces a variable in the dataframe.

Usage

1

Arguments

df

dataframe. The dataframe to modify.

fun

function. The function to run to convert the input into the new input. Whichever argument is passed first to the function is the variable that will be replaced.

Value

Does not return anything, but modifies-in-place the dataframe to replace that variable.

Author(s)

Peter Hurford

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Repaces Sepal.Width to add 1 to each datapoint.
replace_variable(iris, function(Sepal.Width) { Sepal.Width + 1 })

# Repaces Sepal.Length to add the corresponding Sepal.Width to each datapoint for Sepal.Length.
replace_variable(iris, function(Sepal.Length, Sepal.Width) { Sepal.Width + Sepal.Length })

# Usage in a Syberia file
list("Replace Sepal.Length with Sepal.Length + 1" = list(
 replace_variable,
 function(Sepal.Length) Sepal.Length + 1
))

robertzk/syberiaMungebits documentation built on May 25, 2017, 6:40 a.m.