View source: R/compare_rules.R
compare_rules | R Documentation |
Compares multiple sets of association rules, identifies intersections, and optionally displays the results or writes them to a CSV file.
compare_rules(..., display = TRUE, filename = NULL)
... |
Named association rule sets (objects of class |
display |
Logical. If |
filename |
Character string. If provided, writes the results to a CSV file. Default is |
A list containing the intersections of the provided rule sets.
library(arules)
data(BrookTrout)
# Discretize the BrookTrout dataset
discrete_bt <- dtize_df(BrookTrout, cutoff = "mean")
# Generate the first set of rules with a confidence threshold of 0.5
rules1 <- apriori(
discrete_bt,
parameter = list(supp = 0.01, conf = 0.5, target = "rules")
)
# Generate the second set of rules with a higher confidence threshold of 0.6
rules2 <- apriori(
discrete_bt,
parameter = list(supp = 0.01, conf = 0.6, target = "rules")
)
# Compare the two sets of rules and display the intersections
compare_rules(
r1 = rules1,
r2 = rules2,
display = TRUE
)
# If `filename = "intersections.csv"`, the data is saved in a .csv file
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.