new_variable: Creates a new variable in the dataframe.

Description Usage Arguments Value Author(s) Examples

View source: R/new_variable.R

Description

Wrapper around the default multi_column_transformation mungebit to make new variables.

Usage

1
new_variable(df, fun, new_variable, old_variables = NULL)

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.

new_variable

character. The name of the desired new variable.

old_variables

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

Value

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

Author(s)

Peter Hurford

Examples

1
2
3
4
5
6
7
8
9
new_variable(iris, function(Sepal.Width, Sepal.Length) Sepal.Width*2 + Sepal.Length*2, 'Sepal.Perimeter')
new_variable(iris, iris$Sepal.Width, 'Sepal.Width2')

# 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'
))

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