⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 itemmatrix-class.html

📁 本程序是基于linux系统下c++代码
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>R: Class &ldquo;itemMatrix&rdquo; &mdash; Sparse Binary Incidence Matrix to Represent Sets
of Items</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 itemMatrix-class {arules}"><tr><td>itemMatrix-class {arules}</td><td align="right">R Documentation</td></tr></table>
<h2>Class &ldquo;itemMatrix&rdquo; &mdash; Sparse Binary Incidence Matrix to Represent Sets
of Items</h2>


<h3>Description</h3>

<p>
The <code>itemMatrix</code> class is the basic building block
for transactions, itemsets and rules in package <span class="pkg">arules</span>. 
The class contains a sparse Matrix representation of items (a set of
itemsets or transactions) and the corresponding item labels.
</p>


<h3>Objects from the Class</h3>

<p>
Objects can be created by calls of the form <code>new("itemMatrix",
    ...)</code>.
However, most of the time objects will be created by coercion from a
matrix, list or data.frame.
</p>


<h3>Slots</h3>

<dl>
<dt><code>data</code>:</dt><dd>Object of class
<code><a href="../../Matrix/html/ngCMatrix-class.html">ngCMatrix</a></code> 
(from package <span class="pkg">Matrix</span>) which stores 
item occurrences in sparse representation.  Note that the 
<code>ngCMatrix</code> is column-oriented and <code>itemMatrix</code> is
row-oriented with each row representing an element (an itemset, a
transaction, etc.).  As a result, the <code>ngCMatrix</code> in this
slot is always a transposed version of the binary incidence matrix
in <code>itemMatrix</code>.
</dd>
<dt><code>itemInfo</code>:</dt><dd>a data.frame which
contains named vectors of the length equal to the number of
elements in the set.  If the slot is not empty (contains no item
labels), the first element in the data.frame must have the
name <code>"labels"</code> and contain a character vector with the item
labels used for representing an item.  In addition to the item
labels, the data.frame can contain arbitrary named vectors
(of the same length) to represent, e.g., variable names and values
which were used to create the binary items or hierarchical
category information associated with each item label.  
</dd>
<dt><code>itemsetInfo</code>:</dt><dd>a data.frame which may contain additional 
information for the rows (mostly representing itemsets) in the matrix. 
</dd>
</dl>

<h3>Methods</h3>

<dl>
<dt>coerce</dt><dd><code>signature(from = "matrix", to = "itemMatrix")</code>;
expects <code>from</code> to be a binary matrix only containing 0s and 1s.</dd>
<dt>coerce</dt><dd><code>signature(from = "list", to = "itemMatrix")</code>;
<code>from</code> is a list of vectors. Each vector contains one 
set/transaction/....</dd>
<dt>coerce</dt><dd><code>signature(from = "itemMatrix", to = "ngCMatrix")</code>;
access the sparse matrix representation. Note, the <code>ngCMatrix</code> 
contains a transposed from of the itemMatrix.</dd>
<dt>coerce</dt><dd><code>signature(from = "itemMatrix", to = "dgCMatrix")</code>;
access the sparse matrix representation. Note, the <code>dgCMatrix</code> 
contains a transposed from of the itemMatrix.</dd>
<dt>coerce</dt><dd><code>signature(from = "itemMatrix", to = "matrix")</code>; coerces
to a dense 0-1 matrix of <code>storage.mode</code> <code>"integer"</code> instead of 
<code>"double"</code> to save memory.</dd>
<dt>coerce</dt><dd><code>signature(from = "itemMatrix", to = "list")</code>; see also
the methods for <code>LIST</code>.</dd>
<dt>dim</dt><dd><code>signature(x = "itemMatrix")</code>;
returns the dimensions of the itemMatrix.</dd>
<dt>%in%</dt><dd><code>signature(x = "itemMatrix", table = "character")</code>;
matches the strings in <code>table</code> against the item labels 
in <code>x</code> and returns a logical vector indicating if
a row (itemset) in <code>x</code> contains <EM>any</EM> of the
items specified in <code>table</code>.
Note that there is a <code>%in%</code> method with 
<code>signature(x = "itemMatrix", table = "character")</code>. This method is
described in together with <code><a href="match.html">match</a></code>.</dd>
<dt>%ain%</dt><dd><code>signature(x = "itemMatrix", table = "character")</code>; 
matches the strings in <code>table</code> against the item labels 
in <code>x</code> and returns a logical vector indicating if
a row (itemset) in <code>x</code> contains <EM>all</EM> of the
items specified in <code>table</code>.</dd>
<dt>%pin%</dt><dd><code>signature(x = "itemMatrix", table = "character")</code>; 
matches the strings in <code>table</code> against the item labels 
in <code>x</code> (using <EM>partial</EM> matching) and returns a 
logical vector indicating if
a row (itemset) in <code>x</code> contains <EM>any</EM> of the
items specified in <code>table</code>.</dd>
<dt>itemLabels</dt><dd><code>signature(object = "itemMatrix")</code>;
returns the item labels used for encoding as a character vector.</dd>
<dt>itemLabels&lt;-</dt><dd><code>signature(object = "itemMatrix")</code>;
replaces the item labels used for encoding.</dd>
<dt>itemInfo</dt><dd><code>signature(object = "itemMatrix")</code>;
returns the whole item/column information data.frame including
labels.</dd>
<dt>itemInfo&lt;-</dt><dd><code>signature(object = "itemMatrix")</code>;
replaces the item/column info by a data.frame.</dd>
<dt>itemsetInfo</dt><dd><code>signature(object = "itemMatrix")</code>;
returns the item set/row information data.frame.</dd>
<dt>itemsetInfo&lt;-</dt><dd><code>signature(object = "itemMatrix")</code>;
replaces the item set/row info by a data.frame.</dd>
<dt>labels</dt><dd><code>signature(x = "transactions")</code>;
returns the labels (item labels and element names) 
for the matrix as a list of two vectors named <code>items</code>
and <code>elements</code>. The following arguments can be used to customize
the representation of the elements: 
<code>itemSep</code>, 
<code>setStart</code> and 
<code>setEnd</code>.</dd>
<dt>nitems</dt><dd><code>signature(x = "itemMatrix")</code>; returns the number 
of items (number in columns) in the itemMatrix.</dd>
<dt>show</dt><dd><code>signature(object = "itemMatrix")</code></dd>
<dt>summary</dt><dd><code>signature(object = "itemMatrix")</code></dd>
</dl>

<h3>See Also</h3>

<p>
<code><a href="LIST.html">LIST</a></code>,
<code><a href="combine.html">c</a></code>,
<code><a href="duplicated.html">duplicated</a></code>,
<code><a href="inspect.html">inspect</a></code>,
<code><a href="is.superset.html">is.subset</a></code>,
<code><a href="is.superset.html">is.superset</a></code>,
<code><a href="itemFrequency.html">itemFrequency</a></code>,
<code><a href="itemFrequencyPlot.html">itemFrequencyPlot</a></code>,
<code><a href="match.html">match</a></code>,
<code><a href="length.html">length</a></code>,
<code><a href="sets.html">sets</a></code>,
<code><a href="subset.html">subset</a></code>,
<code><a href="unique.html">unique</a></code>,
<code><a href="Xtrct-methods.html">[-methods</a></code>,
<code><a href="image.html">image</a></code>,
<code><a href="../../Matrix/html/ngCMatrix-class.html">ngCMatrix-class</a></code> 
(from <span class="pkg">Matrix</span>),
<code><a href="transactions-class.html">transactions-class</a></code>,
<code><a href="itemsets-class.html">itemsets-class</a></code>,
<code><a href="rules-class.html">rules-class</a></code>
</p>


<h3>Examples</h3>

<pre>
## Generate random data and coerce data to itemMatrix.
m &lt;- matrix(as.integer(runif(100000)&gt;0.8), ncol=20)
dimnames(m) &lt;- list(NULL, paste("item", c(1:20), sep=""))
i &lt;- as(m, "itemMatrix")

## Get the number of elements (rows) in the itemMatrix.
length(i)

## Get first 5 elements (rows) of the itemMatrix as list.
as(i[1:5], "list")

## Get first 5 elements (rows) of the itemMatrix as matrix.
as(i[1:5], "matrix")

## Get first 5 elements (rows) of the itemMatrix as sparse ngCMatrix.
## Warning: for efficiency reasons, the ngCMatrix you get is transposed!
as(i[1:5], "ngCMatrix")
</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 + -