[英]how to get frequency of different lists, in list of lists
假設我有以下列表:
test<-list(c("a","b","c"),c("a,c"),c("a,c"),c("a","b","c"),c("a"))
我想要這樣的結果:
("a","b","c") = 2
("a,c")=2
("a")=1
我試過
> table(test)
Error in table(test) : all arguments must have the same length
這是一個單線。 上面一行數字是向量的名稱。
table(match(test, unique(test)))
#1 2 3
#2 2 1
sapply
和toString
有什么問題:
> table(sapply(test, toString))
a a, b, c a,c
1 2 2
>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.