R arules - a subset of transactions matching a rule

I am using the R arules package . I have some transactions and a rule (see below). I want a subset of transactions to break the rule. How can i do this?

This is the setting:

library(arules)
data(Adult)
summary(Adult)
rules = apriori(Adult,parameter=list(support=0.2,confidence=0.8))
summary(rules)
r=rules[1]

      

I want a subset of transactions that contain the left side of the rule r

but not the right side. There is no such example in the arules documentation. I've tried %in%

, match

and subset

, but I can't get the syntax right.

The documentation for the function subset

has an example of subset rules, but no examples of transaction subsets.

http://rss.acs.unt.edu/Rdoc/library/arules/html/subset.html

+3


source to share


1 answer


In fact, the subset syntax in the arules context is very similar to any other context: you can try this:

subset(transactions, items %in% lhs(r) & !items %in% rhs(r) )

      



Hope this helps!

+3


source







All Articles