transformVar {iNZightTools} | R Documentation |
Transform the values of a numeric variable by applying a mathematical function
transformVar(
.data,
var,
transformation,
name = sprintf("%s.%s", transformation, var)
)
.data |
a dataframe with the variables to transform |
var |
a character of the numeric variable in |
transformation |
a name of a valid mathematical function that can be applied to numeric values, eg. "log", "exp", "sqrt". For squaring, use "square"; for inverting, use "reciprocal" |
name |
the name of the new variable |
the original dataframe containing a new column of the transformed variable with tidyverse code attached
Owen Jin
transformed <- transformVar(iris, var = "Petal.Length",
transformation = "log")
cat(code(transformed))
head(transformed)