【发布时间】:2016-03-17 21:39:49
【问题描述】:
这是查找pairs 的解决方案,但是三元组呢?
如果我有:
consumer=c(1,1,1,1,1,2,2,2,2,3,3,4,4,4,4,5)
items=c("apple","banana","carrot","date","eggplant","apple","banana",
"fig","grape","apple","banana","apple","carrot","date",
"eggplant","apple")
shoppinglists <- data.frame(consumer,items)
table(shoppinglists)
有没有一种简单的方法可以找到最多的三元组组合?例如,三元组“胡萝卜”+“日期”+“茄子”、“苹果”+“胡萝卜”+“日期”、“苹果”+“胡萝卜”+“茄子”和“苹果”+“日期”+ “茄子”分别出现在两个列表中(消费者 1 和 4)。
可以看到有很多并列第二名的一个出现:A+B+C、A+B+D、A+B+E、B+C+D、B+C+E(消费者1 ); A+B+F、A+B+G(消费者2)。
【问题讨论】:
-
我希望只返回三元组的情况,并让结果给我一个三元组列表以及它们各自出现的次数
标签: r count combinations