I would like to use package arules functionalities in my package but can not import the whole package due to name conflicts. object@datafr is a data frame that needs to be coerced to transactions. How should I deal with the second line in the code below?
showrules <- function(object, support=0.05, confidence=0.5){
combinations <- as(object@datafr, "transactions")
rules <- arules::apriori(combinations, parameter = list(support = support,
confidence = confidence), appearance=list(rhs='target=high', default='lhs'))
arules::inspect(rules)
}
I don't know how to call as()
using a namespace qualifier (arules::coerce()
does not work), but luckily apriori()
accepts also data.frames and coerces them internally into transactions. So you can just use:
rules <- arules::apriori(object@datafr, parameter= list(support = support, confidence = confidence), appearance=list(rhs='target=high', default='lhs'))