Description Usage Arguments Value Examples
Creates a matrix of transactions/observations (rows) by association rules (columns). 1 in the matrix indicates that the observation/transaction is eligible for and follows a given rule (LHS & RHS of rule are in the obs/transaction). -1 in the matrix indicates that obs/transaction is eligible for, but does violates the rule (LHS of rule, but not RHS of rule are in obs/transaction). 0 in the matrix indicates that the rule does not apply (LHS of rule not in obs/tranaction).
1 | mergeRules2trans(trans, rhs, lhs)
|
trans |
list of transactions |
rhs |
list of RHS of association rules |
lhs |
list of LHS of association rules |
matrix tying obs/transactions to association rules
1 2 3 4 5 6 7 8 9 10 | library('arules')
library('BBmisc')
data(Adult)
rules <- apriori(Adult, parameter=list(support=0.5, confidence=0.95))
rdf <- rules2df(rules, list=T)
trdf <- as(Adult, 'data.frame')
trdf$items <- gsub('\\{', '', trdf$items)
trdf$items <- gsub('\\}', '', trdf$items)
trdf$items2 <- strsplit(as.character(trdf$items), split=',')
M <- mergeRules2trans(trans=trdf$items2[1:1000], rhs=rdf$rhs, lhs=rdf$lhs)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.