Similar to this question Count number of observations/rows per group and add result to data frame but not quite.
I'd like to transform this
group id_in_group letter
1: A A1 alef
2: A A2 bet
3: A A3 bet
4: B B1 alef
5: B B2 alef
6: B B3 gimel
into this
group aleph bet gimel
1: A 1 2 0
2: B 2 0 1