I wish to generate new columns based on receiving variables in tidy evaluation. For example,
library(dplyr)
some_custom_measure <- function(.data, cola, colb) {
.data %>% mutate("{{ cola }}_x_{{ colb }}" := {{ cola }} * {{ colb }})
}
iris %>%
some_custom_measure(Sepal.Length, Sepal.Width) %>%
head()
The new column will be named Sepal.Length_x_Sepal.Width
.
How do I manipulate the variables as string when forming new name in the custom function? I wish to accomplish something like sepal_length_x_sepal_width