Skip to contents

Uses datatable to create a HTML table widget using the DataTables library. Rules can be interactively filtered and sorted.

Usage

inspectDT(x, ...)

# Default S3 method
inspectDT(x, ...)

# S3 method for class 'rules'
inspectDT(x, precision = 3, ...)

# S3 method for class 'itemsets'
inspectDT(x, precision = 3, ...)

# S3 method for class 'data.frame'
inspectDT(x, precision = 3, ...)

Arguments

x

an object of class "rules" or "itemsets".

...

additional arguments are passed on to DT::datatable().

precision

controls the precision used to print the quality measures (defaults to 2).

Value

A datatable htmlwidget.

References

Hahsler M (2017). arulesViz: Interactive Visualization of Association Rules with R. R Journal, 9(2):163-175. ISSN 2073-4859. doi:10.32614/RJ-2017-047 .

See also

Author

Michael Hahsler

Examples


data(Groceries)
rules <- apriori(Groceries, parameter = list(support = 0.005, confidence = 0.5))
#> Apriori
#> 
#> Parameter specification:
#>  confidence minval smax arem  aval originalSupport maxtime support minlen
#>         0.5    0.1    1 none FALSE            TRUE       5   0.005      1
#>  maxlen target  ext
#>      10  rules TRUE
#> 
#> Algorithmic control:
#>  filter tree heap memopt load sort verbose
#>     0.1 TRUE TRUE  FALSE TRUE    2    TRUE
#> 
#> Absolute minimum support count: 49 
#> 
#> set item appearances ...[0 item(s)] done [0.00s].
#> set transactions ...[169 item(s), 9835 transaction(s)] done [0.00s].
#> sorting and recoding items ... [120 item(s)] done [0.00s].
#> creating transaction tree ... done [0.00s].
#> checking subsets of size 1 2 3 4 done [0.00s].
#> writing ... [120 rule(s)] done [0.00s].
#> creating S4 object  ... done [0.00s].
rules
#> set of 120 rules 

inspectDT(rules)
# for more control on the data table, you can used DATAFRAME() to convert the rules. rules_df <- DATAFRAME(rules, setStart = "", setEnd = "", itemSep = " + ") rules_df$count <- NULL head(rules_df) #> LHS RHS support confidence #> 1 baking powder whole milk 0.009252669 0.5229885 #> 2 other vegetables + oil whole milk 0.005083884 0.5102041 #> 3 root vegetables + onions other vegetables 0.005693950 0.6021505 #> 4 onions + whole milk other vegetables 0.006609049 0.5462185 #> 5 other vegetables + hygiene articles whole milk 0.005185562 0.5425532 #> 6 other vegetables + sugar whole milk 0.006304016 0.5849057 #> coverage lift #> 1 0.017691917 2.046793 #> 2 0.009964413 1.996760 #> 3 0.009456024 3.112008 #> 4 0.012099644 2.822942 #> 5 0.009557702 2.123363 #> 6 0.010777834 2.289115 inspectDT(rules_df)
# Save HTML widget as web page p <- inspectDT(rules) htmlwidgets::saveWidget(p, "arules.html", selfcontained = FALSE) # Note: self-contained seems to make the browser slow. # inspect the widget browseURL("arules.html") # clean up unlink(c("arules.html", "arules_files"), recursive = TRUE)