1
我有一个数据框的列表,索引表示一个家庭结束,另一个开始。我想知道每个系列的statepath列中有多少个类别。数据框列表中的列中有多少个类别?
在我的下面的例子中,我有两个家族,然后我试图得到每个家族中每个statepath类别(233,434,323等)的频率表。
我输入:
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'
因此,我预期输出Freq_statepath会是什么样子:
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’
请使用'dput'向我们提供你的'list',以便这个问题更具有可重现性(http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproduc IBLE-例子)。 – bouncyball