mhahsler / arules

Mining Association Rules and Frequent Itemsets with R
http://mhahsler.github.io/arules
GNU General Public License v3.0
194 stars 42 forks source link

Association rules in R (arules) - how to use the dissimilarity function in arules R #13

Closed leih123 closed 8 years ago

leih123 commented 8 years ago

I am trying to do association rules clustering in R and I am having a problem when I was trying to use the function "dissimilarity". I tried something like this:

dis<-dissimilarity(rules, method = "gupta", args = "trans")

I want to use the "gupta" method to calculate the dissimilarity/distances of the rules, the R help manual said to use "gupta": "The transactions used to mine the associations has to be passed on via args as element "transactions"."

"trans" is my transactions (sparse format) and "rules" is my association rules. An error message said "Error in args$$trans : $ operator is invalid for atomic vectors"

why is it doesn't work?

I have also tried:

dis<-dissimilarity(rules, method = "gupta", args = list("trans"))

Error: Error in .local(x, y, method, args, ...) : Transactions needed in args for this method!

Is there anything wrong with my syntax?

HELP PLEASE !!!!!!!!!!

mhahsler commented 8 years ago

Let's assume your transactions are called Groceries then the syntax is:

 dis <- dissimilarity(rules, method = "gupta", args = list(transactions = Groceries))
leih123 commented 8 years ago

It works, thanks!!