test_data <- data.frame(diag(1, 3))
print(test_data)
## Adding a single variable
add_add_var(data = test_data,
add_var = list("Var1" = c(10, 20)))
## Specifying multiple variables as a list will add values for
## each unique combination
add_add_var(data = test_data,
add_var = list("Var1" = c(10, 20),
"Var2" = c(30, 40)))
## Specifying add_var as a data.frame would simply merge the two data-frames
add_add_var(data = test_data,
add_var = data.frame("Var1" = c(10, 20),
"Var2" = c(30, 40)))
## If the list specified in `add_var` is not named, then the additional
## variables will be automatically named Var1, Var2, Var3, etc.
add_add_var(data = test_data,
add_var = list(c(1, 2), c(3, 4)))
Run the code above in your browser using DataLab