Learn R Programming

iNZightTools (version 1.13.0)

createNewVar: Create new variables

Description

Create a new variable by using a valid R expression and returns the result along with tidyverse code used to generate it.

Usage

createNewVar(.data, new_var = "new.variable", R_exp)

Value

original dataframe containing the new column created from R_exp

with tidyverse code attached

Arguments

.data

a dataframe to which to add a new variable to

new_var

a character of the new variable name. "new.variable" by default

R_exp

a character of a valid R expression which can generate a vector of values

Author

Owen Jin

See Also

code

Examples

Run this code
created <- createNewVar(iris, new_var = "Sepal.Length_less_Sepal.Width",
 "Sepal.Length - Sepal.Width")
cat(code(created))
head(created)

Run the code above in your browser using DataLab