2015-11-10 19 views
0

我想在我的包中使用包arules功能,但由於名稱衝突導致整個包不能導入 。 object @ datafr是需要強制處理事務的數據幀。我應該如何處理下面代碼中的第二行?arules/as /如何將強制方法導入到另一個包中?

showrules <- function(object, support=0.05, confidence=0.5){ 
combinations <- as([email protected], "transactions") 
rules <- arules::apriori(combinations, parameter = list(support = support,   
confidence = confidence), appearance=list(rhs='target=high', default='lhs')) 
arules::inspect(rules) 
} 
+0

你能共享命名空間中的衝突是什麼在困擾你嗎? –

+0

這是'預測'從'統計',我導入,因爲它是,而不是使用它作爲統計::預測 – user2968765

+0

奇怪。 arules導入可以從統計數據中預測並導出一個新的S4預測方法。但是,這不應該掩蓋其他預測方法。 –

回答

1

我不知道如何使用一個名稱空間限定符(arules::coerce()不工作)來調用as(),但幸運的是apriori()也接受data.frames並且強制它們進入內部交易。所以,你可以使用:

rules <- arules::apriori([email protected], parameter= list(support = support, confidence = confidence), appearance=list(rhs='target=high', default='lhs'))

相關問題