Learn R Programming

arules (version 1.3-0)

sort: Sorting Associations

Description

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

Usage

## S3 method for class 'associations':
sort(x, decreasing = TRUE, na.last = NA, 
    by = "support", order = FALSE, ...)

Arguments

x
an object to be sorted.
decreasing
a logical. Should the sort be increasing or decreasing? (default is decreasing)
na.last
for controlling the treatment of NAs. If TRUE, missing values in the data are put last; if FALSE, they are put first; if NA, they are removed.
by
a character string specifying the quality measure stored in x to be used to sort x. If a vector of character strings is specified then the additional strings are used to sort x in case of ties.
order
should a order vector be returned instead of the sorted associations?
...
Further arguments are ignored.

Value

  • An object of the same class as x.

See Also

associations-class

Examples

Run this code
data("Adult")

## Mine rules with APRIORI
rules <- apriori(Adult, parameter = list(supp = 0.6))

## Print the 5 rules sorted by confidence and then support as a data.frame.
as(head(sort(rules, by = c("confidence", "support")), n=5), "data.frame")

## Order of rules by decreasing support
sort(rules, by = "confidence", order = TRUE)

Run the code above in your browser using DataLab