We can try
library(lazyeval) library(dplyr) res1 <- iris %>% mutate_(newVar= interp(~sumVar(x, y), x= as.name("Petal.Length"), y = as.name("Petal.Width")) )
OP Method
res2 <- iris %>% mutate(newVar = sumVar(Petal.Length, Petal.Width)) identical(res1, res2)
Update
In the devel dplyr version ( 0.6.0 will be released soon in April 2017), it can also be with quosure
varNames <- quos(Petal.Length, Petal.Width) res3 <- iris %>% mutate(newVar = sumVar(!!! varNames))
quos are quoted and inside mutate we use !!! to unquote a list for rating
identical(res2, res3)
akrun source share