aggregate {arules} | R Documentation |
Provides the generic functions and the S4 methods for aggregating items in rules and itemsets.
Often an item hierarchy is available for datasets used for association rule mining. For example in a supermarket dataset items like "bread" and "beagle" might belong to the item group (category) "baked goods". The aggregate methods replaces items in transactions, itemsets or rules with item groups as specified by the user.
## S4 method for signature 'itemMatrix' aggregate(x, itemLabels) ## S4 method for signature 'itemsets' aggregate(x, itemLabels) ## S4 method for signature 'rules' aggregate(x, itemLabels)
x |
an transactions, itemsets or rules object. |
itemLabels |
a vector of character strings (factor)
of the same length as items in |
This method returns an object of the same class as x
encoded
with a number of items equal to the number of unique values in
itemLabels
. Note that for associations (itemsets and rules)
the number of associations in the
returned set will most likely be reduced since
several associations might map to the same aggregated association and
aggregate returns a unique set. If several associations map to
a single aggregated association then the quality measures of one
of the original associations is randomly chosen.
data("Groceries") ## Groceries contains a hierarchy stored in itemInfo head(itemInfo(Groceries)) level1 <- itemInfo(Groceries)[["level1"]] levels(level1) ## Aggregate transactions aggregate(Groceries, level1) ## Aggregate rules rules <- apriori(Groceries, parameter=list(supp=0.005, conf=0.5)) rules aggregate(rules, level1)