I have a list of data frames where the index indicates where one family ends and another begins. I would like to know how many categories there are in statepath column in each family.
In my below example I have two families, then I am trying to get a table wiht the frequency of each statepath category (233, 434, 323, etc) in each family.
My input:
List <- 
'$`1`
Chr  Start   End Family Statepath
1   187546286   187552094   father  233
3   108028534   108032021   father  434
1   4864403 4878685 mother  323 
1   18898657    18904908    mother 322
2   460238  461771  offspring   322
3   108028534   108032021   offspring   434
$’2’
Chr  Start   End Family Statepath
1   71481449    71532983    father  535
2   74507242    74511395    father  233
2   181864092   181864690   mother  322
1   71481449    71532983    offspring   535
2   181864092   181864690   offspring   322
3   160057791   160113642   offspring   335'
Thus, my expected output Freq_statepath would look like:
Freq_statepath <- ‘Statepath    Family_1    Family_2
233 1   1
434 2   0
323 1   0
322 2   2
535 0   2
335 0   1’
 
    