We could translate it to a symbol using Rlang and then evaluate it using!!
function(df, old.col, new.col), f.tidy
percent > df percent
(new.col):= mutate(!!
(old.col + 1) rlang::sym
}
df = df, old.col = old.col, and new.col = new.col in f.tidy
Test Tcy Dan at #
#1 1 4 5
#2 2 5 6
#3 3 6 7
Or another option is mutate_at with rename_at
f.tidy <- function(df, old.col, new.col) {
df %>%
mutate_at(vars(old.col), funs(new = .+ 1)) %>%
rename_at(vars(matches("new")), ~ new.col)
}
f.tidy(df = df, old.col = old.col, new.col = new.col)
# test tcy dan
#1 1 4 5
#2 2 5 6
#3 3 6 7