My biggest takeaway from Hadley's talk Tidyverse: The Greatest Mistakes is the existence of the embrace {{ }} operator for doing tidyeval. It lets you do
my_summarise <- function(df, var, group){
df %>%
group_by({{group}}) %>%
summarise(mean = mean({{var}}))
}
my_summarise(mtcars, mpg, cyl)
Instead of the usual enquo, !! cycle of doing things
My question is twofold:
a) where is the documentation for this operator? I can't seem to google or ctrl+f for this in the dplyr release notes
b) does the 'embrace' operator work with ...?. For example, is there a way to make this example work using {{ }}?
my_summarise <- function(df, var, ...){
df %>%
group_by({{...}}) %>%
summarise(mean = mean({{var}}))
}
my_summarise(mtcars, mpg, cyl, gear)