📄 subset.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>R: Subsetting Itemsets, Rules and Transactions</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../R.css">
</head><body>
<table width="100%" summary="page for subset {arules}"><tr><td>subset {arules}</td><td align="right">R Documentation</td></tr></table>
<h2>Subsetting Itemsets, Rules and Transactions</h2>
<h3>Description</h3>
<p>
Provides the generic function <code>subset</code> and S4 methods to subset
associations or transactions (itemMatrix) which meet certain conditions
(e.g., contains certain items or satisfies a minimum lift).
</p>
<h3>Usage</h3>
<pre>
subset(x, ...)
## S4 method for signature 'itemMatrix':
subset(x, subset, ...)
## S4 method for signature 'itemsets':
subset(x, subset, ...)
## S4 method for signature 'rules':
subset(x, subset, ...)
## S4 method for signature 'itemMatrix':
subset(x, subset, ...)
</pre>
<h3>Arguments</h3>
<table summary="R argblock">
<tr valign="top"><td><code>x</code></td>
<td>
object to be subsetted.</td></tr>
<tr valign="top"><td><code>subset</code></td>
<td>
logical expression indicating elements to keep.</td></tr>
<tr valign="top"><td><code>...</code></td>
<td>
further arguments to be passed to or from other methods.</td></tr>
</table>
<h3>Details</h3>
<p>
<code>subset</code> works on the rows/itemsets/rules of <code>x</code>. The
expression given in <code>subset</code> will be evaluated using <code>x</code>,
so the items (lhs/rhs/items) and the columns in the quality
data.frame can be directly referred to by their names.
</p>
<p>
Important operators to select itemsets containing items specified by their
labels are <code>%in%</code> (select itemsets matching
<EM>any</EM> given item), <code>%ain%</code> (select only itemsets matching
<EM>all</EM> given item) and <code>%pin%</code> (<code>%in%</code> with partial
matching).
</p>
<h3>Value</h3>
<p>
An object of the same class as <code>x</code> containing only the
elements which satisfy the conditions.</p>
<h3>See Also</h3>
<p>
<code><a href="itemMatrix-class.html">itemMatrix-class</a></code>,
<code><a href="itemsets-class.html">itemsets-class</a></code>,
<code><a href="rules-class.html">rules-class</a></code>,
<code><a href="transactions-class.html">transactions-class</a></code>
</p>
<h3>Examples</h3>
<pre>
data("Adult")
rules <- apriori(Adult)
## select all rules with item "marital-status=Never-married" in
## the right-hand-side and lift > 2
rules.sub <- subset(rules, subset = rhs %in% "marital-status=Never-married"
& lift > 2)
## use partial matching for all items corresponding to the variable
## "marital-status"
rules.sub <- subset(rules, subset = rhs %pin% "marital-status=")
## select only rules with items "age=Young" and "workclass=Private" in
## the left-hand-side
rules.sub <- subset(rules, subset = lhs %ain%
c("age=Young", "workclass=Private"))
</pre>
<hr><div align="center">[Package <em>arules</em> version 0.6-6 <a href="00Index.html">Index]</a></div>
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -