Huge help! I was able to use one of your workarounds successfully.
I share the intuition you express in the issue page, this is not such an uncommon task 
I had to make a slight change to give both of the alternative variables a slightly different name:
generate dataset, alternate variables named with .v1 or .v2
iris_v1 <- iris %>%
tibble() %>%
rename_all(
funs(paste0(., ".v1")))
iris.v1.AND.v2 <- iris %>%
tibble() %>%
mutate_at(vars(Sepal.Length:Petal.Width), ~.*5) %>%
rename_all(
funs(paste0(., ".v2"))) %>%
bind_cols(iris_v1)
I took your function:
tidyverse workaround: custom function + reduce
gen_vars <- function(df, x) {
mutate(df,
"{x}.Ratio" := case_when(
!! sym(paste0(x, ".Length")) / !! sym(paste0(x, ".Width")) > 2 ~ T,
T ~ F
)
)
}
sym
my_vars <- c("Petal", "Sepal")
iris %>%
reduce(my_vars, gen_vars, .init = .)
And modified it for my purpose, which worked !
gen_vars_mod <- function(df, x) {
mutate(df,
"{x}.iris_or_alternative" := case_when(
!! sym(paste0(x, ".v1")) > 1 & !! sym(paste0(x, ".v1")) < 4 ~ !! sym(paste0(x, ".v2")),
!! sym(paste0(x, ".v1")) <= 1 | !! sym(paste0(x, ".v1")) >=5 ~ !! sym(paste0(x, ".v1")),
!! sym(paste0(x, ".v1")) >=4 & !! sym(paste0(x, ".v1")) <5 ~ !! sym(paste0(x, ".v1"))+1 ,
T~ !! sym(paste0(x, ".v1"))
)
)
}
iris.v1.OR.v2 <- iris.v1.AND.v2 %>%
reduce(my_vars, gen_vars_mod, .init = .) %>%
select(contains("or"), Species.v1)%>%
rename(Species = "Species.v1")
I tried getting it to work with the original dataset, but using this this function did not work
gen_vars_mod <- function(df, x) {
mutate(df,
"{x}.iris_or_alternative" := case_when(
x > 1 & x < 4 ~ !! sym(paste0(x, ".alternative")),
x <= 1 | x >=5 ~ x,
x >=4 x <5. ~ x+1 ,
T~ x
)
)
}
Thank you!