Sort Associations
Provides the method sort
to sort elements
in class associations
(e.g., itemsets or rules)
according to the value of measures stored in the association's slot
quality
(e.g., support).
## S4 method for signature 'associations' sort(x, decreasing = TRUE, na.last = NA, by = "support", order = FALSE, ...) ## S4 method for signature 'associations' head(x, n = 6L, by = NULL, decreasing = TRUE, ...) ## S4 method for signature 'associations' tail(x, n = 6L, by = NULL, decreasing = TRUE, ...)
x |
an object to be sorted. |
decreasing |
a logical. Should the sort be increasing or decreasing? (default is decreasing) |
na.last |
na.last is not supported for associations. NAs are always put last. |
by |
a character string specifying the quality measure stored in
|
order |
should a order vector be returned instead of the sorted associations? |
n |
a single integer indicating the number of associations returned. |
... |
Further arguments are ignored. |
sort
is relatively slow for large sets of associations since it
has to copy and rearrange a large data structure.
Note that sorting creates a second copy of the set of associations which can
be slow and memory consuming for large sets.
With order = TRUE
a integer vector with the order is returned instead
of the reordered associations.
If only the top n
associations are needed then head
using by
performs this faster than calling sort
and then head
since
it does it without copying and rearranging all the data.
tail
works in the same way.
An object of the same class as x
.
Michael Hahsler
data("Adult") ## Mine rules with APRIORI rules <- apriori(Adult, parameter = list(supp = 0.6)) rules_by_lift <- sort(rules, by = "lift") inspect(head(rules)) inspect(head(rules_by_lift)) ## A faster/less memory consuming way to get the top 5 rules according to lift ## (see Details section) inspect(head(rules, n = 5, by = "lift"))
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.