[英]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.