0
func_cust<-function(res) {
   res <-
      cust_repay%>%
      group_by(Customer,
               Year=lubridate::year(Month),
               Month=lubridate::month(Month),
               Product) %>%
      summarise(tot_amt = sum(Amount))%>%
      arrange(desc(tot_amt))%>%
      filter(row_number()<= 10)
   print(res)
}

View(func_cust("Gold"))
Vinícius Félix
  • 8,448
  • 6
  • 16
  • 32
  • Here's the shortest relevant intro I could find: https://www.tidyverse.org/blog/2019/06/rlang-0-4-0/#a-simpler-interpolation-pattern-with- – Jon Spring Sep 02 '21 at 17:08
  • Here's an older question that also asks how to control `dplyr::filter` inside a function, but `dplyr` has been updated since it was asked to make this task less ungainly and complicated. See note above re: "curly curly" operator. https://stackoverflow.com/questions/52560443/create-r-function-using-dplyrfilter-problem/52563183#52563183 – Jon Spring Sep 02 '21 at 17:10

0 Answers0