mergeRules2trans: Link transactions/observations to association rules

Description Usage Arguments Value Examples

Description

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).

Usage

1
mergeRules2trans(trans, rhs, lhs)

Arguments

trans

list of transactions

rhs

list of RHS of association rules

lhs

list of LHS of association rules

Value

matrix tying obs/transactions to association rules

Examples

 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)

brooksandrew/Rsenal documentation built on May 13, 2019, 7:50 a.m.