I am trying to sum up a filtered column to count the number of occurrences. How can i sum the character data type.
bowler dismissal_type
TS Mills bowled
TS Mills bowled
A Nehra bowled
Pj cummins bowled
TS Mills bowled
A Nehra bowled
I tried to sum the dismissal_type
but throws me an errors saying can't sum character type
bowled <- innings%>%
filter(dismissal_type == "bowled")%>%
group_by(bowler)%>%
summarize_each(bowled = sum(dismissal_type == "bowled"))%>%
top_n()
It seems simple but can't get it done. All i want to output is:
bowler dismissal_type n
TS Mills bowled 3
A Nehra bowled 2
Pj cummins bowled 1