How to pass a filtering criteria to a function?

Thank you for your help and recommendations.

I still wondering, how to decide when is enough to use only the dots and when the quotation is required. In case of first example both solution are working.

fraction1 <- function(df, group, ...){
  group = enquo(group)
  df %>% 
    filter(...) %>% 

vs

fraction1 <- function(df, group, ...){
  group = enquo(group)
  condition <- enquos(...)
  df %>% 
    filter(!!!condition) %>%

But if I interpret correctly Hadley’s answer, even in the first case the tidyeval is working behind the scenes.

1 Like