new_variable: Creates a new variable in the dataframe.

Description Arguments Value Examples

Description

Wrapper around the default multi_column_transformation mungebit to make new variables.

Arguments

df

dataframe. The dataframe to modify.

fun

function. The function to run to convert old_variables to new_variables. Also can take a non-function expression that will be converted to function() expression.

old_variables

character. The names of the variables needed to make the new_variable.

new_variable

character. The name of the desired new variable.

Value

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
new_variable()$run(iris, function(Sepal.Width, Sepal.Length) Sepal.Width*2 + Sepal.Length*2, 'Sepal.Perimeter')
#TODO: (RK) Fix broken example.
#new_variable()$run(iris, iris$Sepal.Width, 'Sepal.Width2')

## Not run: 
  # Usage in a Syberia file
  list("Make new variable" = list(
    new_variable,
    function(Sepal.Width, Sepal.Length) Sepal.Width*2 + Sepal.Length*2,
    'Sepal.Perimeter'
  ))

## End(Not run)

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