Hi, I'm new to tidyeval and wanted to do the following:
# This is working as expected
eval_tidy(quo("a" %>% paste("b")))
# "a b"
I expected the following snipped to return the same result as above but gettingsomething else. What am I missing here? How could I get the above result when having var_1 and var_2 as quo's?
When you replace quo by expr for the two vars, it is working as expected
I still try to understand the difference between both to be able to explain it clearly by words. I think I understand it conceptually but not enough to explain clearly. Great example then !
My understanding was, that the advantage of quosures over extressions is, that they take into account the environment. I my use case this would be useful so I am looking for a solution using "quo".
The wrapr dot pipe is a bit more circumspect and thus more compatible with other R non-standard systems than magrittr pipe is. For example it can already work your example (a difference being wrapr pipe requires explicit dots).
library("rlang")
library("magrittr")
library("wrapr")
var_1 <- expr("a")
var_2 <- expr(paste("b"))
eval_tidy(quo(!!var_1 %>% !!var_2)) # works get "a b"
var_1 <- quo("a")
var_2 <- quo(paste("b"))
eval_tidy(expr(!!var_1 %>% !!var_2)) # fails got a magrittr closure back
var_1 <- quo("a")
var_2 <- quo(paste(., "b"))
eval_tidy(expr(!!var_1 %.>% !!var_2)) # works get "a b"