无法识别绑定功能

时间:2017-03-19 10:56:59

标签: r

我正在使用Titanic数据集,从中提取一些数据。

然后我尝试根据Aprior提取规则:

library(arules)
rules<- apriori(df)

然后我问了两个指标提升 oddsRatio

metrics <- interestMeasure(rules, c("oddsRatio","lift"),transactions = df)
rules<-sort(rules, decreasing = TRUE, by = "lift")
inspect(head(rules ))
head(metrics)

但是,我需要根据oddsRatio对结果进行排序,所以我做了

dataFramedRules <-quality(rules)
rules<-cbind(dataFramedRules,metrics)

在最后一行之前一切都很顺利

rules<-sort(rules, decreasing = TRUE, by = "oddsRatio")

但在最后一行它抱怨:

  

[.data.frame中的错误(x,顺序(x,na.last = na.last,减少=减少)):         选择了未定义的列

似乎无法识别绑定列oddsRatio。 我该如何解决?

1 个答案:

答案 0 :(得分:0)

问题通过以下代码解决:

quality(rules) <- cbind(quality(rules), oddsRatio = interestMeasure(rules, measure ="oddsRatio", df))
inspect(head(sort(rules, by = "oddsRatio")))