Search code examples
rarules

Is is.subset not working in R?


require(arules)
Groceries <- read.transactions("C:/Users/IBM_ADMIN/Desktopgroceries.csv",sep=",")

 m1 <- apriori(Groceries,parameter=list(support=0.007,confidence=0.25,minlen=2))

subset.matrix <- is.subset(m1, m1)

#this piece of line is not working

This produces the following error message:

Error in match(x, table, nomatch = 0L) : 
  'match' requires vector arguments

Please do help me.


Solution

  • apriori returns rules object, not a vector:

    data("Adult")
    ## Mine association rules.
    rules <- apriori(Adult, 
        parameter = list(supp = 0.5, conf = 0.9, target = "rules"))
    class(rules)
    # [1] "rules"
    

    if you want to compare lists of rules you will need to transform this object to a data.frame, e.g.:

    rules.df <- as(rules, "data.frame")
    is.subset(rules.df$rules, rules.df$rules)