I am trying to find association rules using the apriori function from arules package in R.
rules <- apriori(data=data, parameter=list(supp=0.001,conf = 0.08),
appearance = list(default="lhs",rhs="YOGHURT"),
control = list(verbose=F))
rules <- sort(rules, decreasing=TRUE,by="confidence")
inspect(rules[1:3])
lhs rhs support confidence lift
1. {A,B} {C} 0.04 0.96 0.25
2. {C,A} {D} 0.05 0.95 0.26
3. {B,D} {A,C} 0.03 0.93 0.24
With the code showed above I got some association rules saved in the variable "rules" ordered by confidence in a decreasing way. But I would like to order these rules by confidence and by lift at the same time. I tried this but I got an error:
rules <- sort(rules, decreasing=TRUE,by=c("confidence","lift"))
Error in .subset2(x, i, exact = exact) : subscript out of bounds
Is there a way to sort rules by confidence and lift at the same time?
rules
? What is the desired output? What are you getting instead? Please provide a minimum reproducible example. – nicoARules
library already supportssort(..)
now as it's used in the question body. So the answers are actually no longer necessary. – Emadpres