replace_variable: Replaces a variable in the dataframe.

Description Arguments Value Author(s) Examples

Description

Replaces a variable in the dataframe.

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
12
13
14
# Repaces Sepal.Width to add 1 to each datapoint.
replace_variable()$run(iris, function(Sepal.Width) { Sepal.Width + 1 })

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

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

## End(Not run)

syberia/syberiaMungebits2 documentation built on May 30, 2019, 10:42 p.m.