I used to use mutate_ with .dots argument to evaluate a set of formulas inside a function using a mix of user supplied variables (in string format) and variables calculated inside the function (as the b variable below) as follows:
require(dplyr)
f <- function(data, a)
{
b <- "Sepal.Length"
mutate_call <- list(new_1 = lazyeval::interp( ~ a*10, a=as.name(a)),
new_2 = lazyeval::interp( ~ b*10, b=as.name(b)) )
data %>%
as_tibble() %>%
mutate_(.dots = mutate_call) %>%
head() %>%
print()
}
f(iris, "Sepal.Width")
however, when transitioning to recent dplyr version, this is no longer possible (unless I keep using the deprecated version mutate_). How can I achieve the same result as f does using mutate instead of mutate_?
It would much easier if I could keep using the formulas.