Creating specific rules using arules in r

I have a large data set (matrix of 0s and 1s) with 200 variables (each variable is an element) and almost 1M rows (each row is a transaction). I use the arules package in R to develop association rules. I counted 2 elements , and I want to create all the rules with at least one of them on the left side . The code I wrote is:

rules <- apriori(data, parameter = list(support = 0.1, confidence = 0.1,
minlen =2),appearance = list(lhs=c("itemA=1","itemB=1"),default="rhs"))

But this code creates rules that have only itemA, only itemB, or only both of them on the left side of the rules. I really appreciate if you could help me.

+2
source share
1 answer

, :

rules <- apriori(data, parameter = list(support = 0.1, confidence = 0.1,minlen =2))
subrules <- subset(rules, subset = lhs %in% c("itemA=1","itemB=1"))
+3

All Articles