Provides the generic function inspect() and methods to display
associations and transactions plus additional information formatted for
online inspection.
Usage
inspect(x, ...)
# S4 method for class 'itemsets'
inspect(x, itemSep = ", ", setStart = "{", setEnd = "}", linebreak = NULL, ...)
# S4 method for class 'rules'
inspect(
x,
itemSep = ", ",
setStart = "{",
setEnd = "}",
ruleSep = "=>",
linebreak = NULL,
...
)
# S4 method for class 'transactions'
inspect(x, itemSep = ", ", setStart = "{", setEnd = "}", linebreak = NULL, ...)
# S4 method for class 'itemMatrix'
inspect(x, itemSep = ", ", setStart = "{", setEnd = "}", linebreak = NULL, ...)
# S4 method for class 'tidLists'
inspect(x, ...)Arguments
- x
a set of associations or transactions or an itemMatrix.
- ...
additional arguments. can be used to customize the output:
- itemSep
item separator
- setStart
set start symbol
- setEnd
set end symbol
- linebreak
print only one element per line in case the output lines get very long?
- ruleSep
rule separator
Details
inspect() prints the results directly. If you need to create a data.frame
with a human readable version, then you can use DATAFRAME().
See also
Other associations functions:
abbreviate(),
associations-class,
c,
duplicated(),
extract,
is.closed(),
is.generator(),
is.maximal(),
is.redundant(),
is.significant(),
is.superset(),
itemsets-class,
match(),
rules-class,
sample(),
sets,
size(),
sort(),
unique()
Other itemMatrix and transactions functions:
abbreviate(),
c,
crossTable(),
duplicated(),
extract,
hierarchy,
image,
is.superset(),
itemFrequency(),
itemFrequencyPlot(),
itemMatrix-class,
itemwiseSetOps,
match(),
merge(),
random.transactions(),
sample(),
sets,
size(),
supportingTransactions(),
tidLists-class,
transactions-class,
unique()
Examples
data("Adult")
rules <- apriori(Adult)
#> Apriori
#>
#> Parameter specification:
#> confidence minval smax arem aval originalSupport maxtime support minlen
#> 0.8 0.1 1 none FALSE TRUE 5 0.1 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: 4884
#>
#> set item appearances ...[0 item(s)] done [0.00s].
#> set transactions ...[115 item(s), 48842 transaction(s)] done [0.03s].
#> sorting and recoding items ... [31 item(s)] done [0.00s].
#> creating transaction tree ... done [0.02s].
#> checking subsets of size 1 2 3 4 5 6 7 8 9 done [0.08s].
#> writing ... [6137 rule(s)] done [0.00s].
#> creating S4 object ... done [0.01s].
## display some rules
inspect(rules[1000:1001])
#> lhs rhs support confidence coverage lift count
#> [1] {education=Some-college,
#> sex=Male,
#> capital-loss=None} => {native-country=United-States} 0.1208181 0.9256471 0.1305229 1.031449 5901
#> [2] {education=Some-college,
#> sex=Male,
#> capital-gain=None} => {capital-loss=None} 0.1199992 0.9474620 0.1266533 0.993899 5861
inspect(rules[1000:1001],
ruleSep = "~~>", itemSep = " + ", setStart = "", setEnd = "",
linebreak = FALSE
)
#> lhs
#> [1] education=Some-college + sex=Male + capital-loss=None ~~>
#> [2] education=Some-college + sex=Male + capital-gain=None ~~>
#> rhs support confidence coverage lift count
#> [1] native-country=United-States 0.1208181 0.9256471 0.1305229 1.031449 5901
#> [2] capital-loss=None 0.1199992 0.9474620 0.1266533 0.993899 5861
## to get rules in readable format, use coercion or DATAFRAME with additional parameters.
as(rules[1000:1001], "data.frame")
#> rules
#> 1000 {education=Some-college,sex=Male,capital-loss=None} => {native-country=United-States}
#> 1001 {education=Some-college,sex=Male,capital-gain=None} => {capital-loss=None}
#> support confidence coverage lift count
#> 1000 0.1208181 0.9256471 0.1305229 1.031449 5901
#> 1001 0.1199992 0.9474620 0.1266533 0.993899 5861
DATAFRAME(rules[1000:1001])
#> LHS
#> 1000 {education=Some-college,sex=Male,capital-loss=None}
#> 1001 {education=Some-college,sex=Male,capital-gain=None}
#> RHS support confidence coverage lift
#> 1000 {native-country=United-States} 0.1208181 0.9256471 0.1305229 1.031449
#> 1001 {capital-loss=None} 0.1199992 0.9474620 0.1266533 0.993899
#> count
#> 1000 5901
#> 1001 5861
DATAFRAME(rules[1000:1001], separate = TRUE, setStart = "", setEnd = "")
#> LHS
#> 1000 education=Some-college,sex=Male,capital-loss=None
#> 1001 education=Some-college,sex=Male,capital-gain=None
#> RHS support confidence coverage lift count
#> 1000 native-country=United-States 0.1208181 0.9256471 0.1305229 1.031449 5901
#> 1001 capital-loss=None 0.1199992 0.9474620 0.1266533 0.993899 5861