【问题标题】:matching transaction with %in% in arules package R将交易与 arules 包 R 中的 %in% 匹配
【发布时间】:2013-07-23 08:52:28
【问题描述】:

我需要找到符合某些规则的交易。 以下代码曾经可以工作,但现在 R 从基础包中识别 %in%,而不是从 arules

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

  return(matchedTrx)
}

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

如果我使用:

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

我得到错误:

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

感谢您的帮助。

【问题讨论】:

  • 也许this 来自交叉验证的答案可以帮助您找到匹配规则。
  • 那么library(arules)...?
  • arules 已加载

标签: r match arules


【解决方案1】:

试试这个而不是 %in%,我希望它会有所帮助

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

【讨论】:

    【解决方案2】:

    试试这个:

    which(arules::'%in%'(transactions,rules))
    

    【讨论】:

    • Error in which(arules::"%in%"(transactions, rules)):在为函数“which”选择方法时评估参数“x”时出错:匹配错误(x , table, nomatch = 0) : 'match' 需要向量参数
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-13
    • 1970-01-01
    • 1970-01-01
    • 2020-06-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多