You can do:
df %>% filter(y == .GlobalEnv$y)
or
df %>% filter(y == .GlobalEnv[["y"]])
or
both of them work in this context, but will not, if all this happens inside the function. But get will be:
df %>% filter(y == get("y")) f = function(df, y){df %>% filter(y==get("y"))}
So use get .
Or just use df[df$y==y,] instead of dplyr .
Spacedman
source share