Description Usage Arguments Value Author(s) Examples
Wrapper around the default multi_column_transformation mungebit to make new variables.
1 | new_variable(df, fun, new_variable, old_variables = NULL)
|
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. |
Does not return anything, but modifies-in-place the dataframe to have that new variable.
Peter Hurford
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'
))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.