Search code examples
rrstudioaprioriarules

Constraining association rules by multiple strings


I was wondering if anyone knows how to constrain the left and right hand sides in apriori (arules) by pointing to a .csv containing the constraints.

A very similar question was asked and answered in this post for anyone else struggling with something similar.

rules_sales <- apriori(sales, 
                       parameter=list(support=0.001, confidence=0.5, minlen=2, maxlen=2), 
                       appearance=list(lhs=c("HouseOwnerFlag=0", "HouseOwnerFlag=1"), 
                       rhs=paste0("Product=", unique(sales$Product)), default="none"))

However I have a fairly substantial list of constraints to apply and am trying to avoid typing or copying and pasting directly into R.

Thanks for looking!


Solution

  • Verena Haunschmid provides the answer to this in Solution 2: of their post:

    How to get items for both LHS and RHS for only specific columns in arules?