I have a following dataframe in R
Serivce Codes
ABS RT
ABS RT
ABS TY
ABS DR
ABS DR
ABS DR
ABS DR
DEF RT
DEF RT
DEF TY
DEF DR
DEF DR
DEF DR
DEF DR
DEF TY
DEF SE
DEF SE
What I want is service wise code count in descending order
Serivce Codes Count
ABS DR 4
ABS RT 2
ABS TY 1
DEF DR 4
DEF RT 2
DEF TY 2
I am doing following in r
df%>%
group_by(Service,Codes) %>%
summarise(Count = n()) %>%
top_n(n=3,wt = Count) %>%
arrange(desc(Count)) %>%
as.data.frame()
But,it does not give me what is intended.