2017-07-24 68 views
-1

運行檢查命令後,我得到了錯誤插槽[R編程,購物籃分析

錯誤(X,S)[我]:下標越界。

basket_rules <- apriori(txn, parameter = list(sup = 0.005, conf = 0.01, target="rules")) 
basket.sorted <- sort(basket_rules, by = "lift") 
itemFrequencyPlot(txn, topN = 25) 
inspect(basket.sorted[1:5]) 

誰能幫助我?

回答

1

basket.sorted據推測小於5條規則,所以5出界。見例如

library(arules) 
data("Adult") 
basket_rules <- apriori(Adult, parameter = list(sup = 0.9, conf = 0.5, target="rules")) 
basket.sorted <- sort(basket_rules, by = "lift") 
inspect(basket.sorted[1:5]) 
# Error in slot(x, s)[i] : subscript out of bounds 
basket.sorted 
# set of 2 rules 
inspect(basket.sorted[1:2]) 
#  lhs rhs     support confidence lift 
# [1] {} => {capital-gain=None} 0.9173867 0.9173867 1 
# [2] {} => {capital-loss=None} 0.9532779 0.9532779 1 
+0

是的GT感謝:-) –