Hi, I have a following problem:
I use this command to compute mean and sum of purchase_amount column.
data %>% select(purchase_month, purchase_amount) %>% group_by(purchase_month) %>%
summarise(across(
.cols = is.numeric,
.fns = list(Mean = mean, Sum = sum) ,
.names = "{col}_{fn}"
))
However, I also need to compute the total number of purchases in purchase_month.
I tried this:
.fns = list(Mean = mean, Sum = sum, Count = n() )
but it does not work. I also tried Count = count, Count = .N
Can you help me please? Thanks a lot.