I would like also to create a data.frame with the rules in the row and the column items filled in according to 1 or 0.
Example:
A B C D
A + B + C 1 1 1 0
A + D + C 1 0 1 1
Any suggestions? The idea is to create a heatmap. Thanks a lot!
as(x, "matrix")
converts an itemMatrix
into a logical matrix. Example:
data("Adult")
rules <- apriori(Adult,
parameter = list(supp = 0.5, conf = 0.9, target = "rules"))
as(items(rules), "matrix")
items()
extracts the LHS and RHS of the rule as a single itemMatrix
.
You can convert the matrix into a data.frame and change it from logical to 0-1 (using storage.mode()
).