Add Complement-items to Transactions
Provides the generic function addComplement
and the S4 methods for
transactions. This function adds for given items complement items. That is
it adds an artificial item to each transactions which does not
contain the original item. Such items are also called negative items (Antonie et al, 2014).
addComplement(x, labels, complementLabels=NULL)
x |
an object of class |
labels |
character strings; item labels for which complements should be created. |
complementLabels |
character strings; labels for the artificial complement-items. If omitted then the original label is prepended by "!" to form the complement-item label. |
Returns an object of class transactions
with complement-items added.
Michael Hahsler
Antonie L., Li J., Zaiane O. (2014) Negative Association Rules. In: Aggarwal C., Han J. (eds) Frequent Pattern Mining, Springer International Publishing, pp. 135-145. doi: 10.1007/978-3-319-07821-2_6
data("Groceries") ## add a complement-items for "whole milk" and "other vegetables" g2 <- addComplement(Groceries, c("whole milk", "other vegetables")) g2 tail(itemInfo(g2)) inspect(head(g2, 3)) ## use a custom label for the complement-item g3 <- addComplement(g2, "coffee", complementLabels = "NO coffee") inspect(head(g2, 3)) ## add complements for all items (this is excessive for this dataset) g4 <- addComplement(Groceries, itemLabels(Groceries)) g4 ## add complements for all items with a minimum support of 0.1 g5 <- addComplement(Groceries, names(which(itemFrequency(Groceries) >= 0.1))) g5
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.