与规则包R中的%in%匹配的交易 [英] matching transaction with %in% in arules package R

查看:104
本文介绍了与规则包R中的%in%匹配的交易的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要找到符合某些规则的交易. 以下代码曾经可以使用,但是现在R从基本包中识别出%in%,而不是从 arles 中识别出.

I need to find transactions matching some rules. The following code used to work, but now R recognise %in% from the base package instead from arules.

matchRules=function(rules,transactions){
  id.match=which(transactions %in% rules)
  matchedTrx=transactions[id.match]
  summary(matchedTrx)

  return(matchedTrx)
}

我尝试了arules::%in%,但是它不起作用.

I tried arules::%in% but it doesn't work.

如果我使用:

id.match=which(transactions arules::%in% rules)

我收到错误消息:

unexpected symbol in "id.match=which(transactions arules"

感谢您的帮助.

推荐答案

尝试使用此方法代替%in%,希望对您有所帮助

Try this instead of %in%, I hope it helps

library(arules)    
st <- supportingTransactions(rules, transactions)
Transaction_IDs <- as(st,"list")

这篇关于与规则包R中的%in%匹配的交易的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆