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

📄 transactions-class.html

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


<h3>Description</h3>

<p>
The <code>transactions</code> class represents transaction data used for
mining itemsets or rules.  It is a direct extension of class
<code><a href="itemMatrix-class.html">itemMatrix</a></code> to store a binary incidence
matrix, item labels, and optionally transaction IDs and user IDs.
</p>


<h3>Objects from the Class</h3>

<p>
Objects are created by coercion from objects of other classes or by
calls of the form <code>new("transactions", ...)</code>.
</p>


<h3>Slots</h3>

<dl>
<dt><code>transactionInfo</code>:</dt><dd>a data.frame
with vectors of the same length as the number of
transactions.  Each vector can hold additional information, e.g.,
store transaction IDs or user IDs for each transaction.</dd>
<dt><code>data</code>:</dt><dd>object of class
<code><a href="../../Matrix/html/ngCMatrix-class.html">ngCMatrix</a></code> to store the
binary incidence matrix (see
<code><a href="itemMatrix-class.html">itemMatrix</a></code> class)</dd> 
<dt><code>itemInfo</code>:</dt><dd>a data.frame to store 
item labels (see <code><a href="itemMatrix-class.html">itemMatrix</a></code> class)</dd>
</dl>

<h3>Extends</h3>

<p>
Class <code><a href="itemMatrix-class.html">itemMatrix</a></code>, directly.
</p>


<h3>Methods</h3>

<dl>
<dt>coerce</dt><dd><code>signature(from = "matrix", to = "transactions")</code>;
produces a transactions data set from a binary incidence matrix. 
The row names are used as item labels and the column names are
stores as transaction IDs.
</dd>
<dt>coerce</dt><dd><code>signature(from = "list", to = "transactions")</code>;
produces a transactions data set from a list.  The names of the
items in the list are used as item labels and the item IDs and the 
incidence matrix is produced automatically.
</dd>
<dt>coerce</dt><dd><code>signature(from = "transactions", to = "matrix")</code></dd>
<dt>coerce</dt><dd><code>signature(from = "transactions", to = "list")</code></dd>
<dt>coerce</dt><dd><code>signature(from = "data.frame", to = "transactions")</code>; 
recodes the data frame containing only categorical variables (all
have to be factors) into a binary transaction data set.  The needed
number of dummy items are automatically generated.  The item
labels are generated by concatenating variable names and levels with
a <span class="samp">"="</span>.
The variable names and levels are stored in the labels data frame
as the components <code>variables</code> and <code>levels</code>.
Note that <code>NA</code> in one of the levels is replaced by the string
&ldquo;NA&rdquo;, i.e. the special meaning is lost.</dd>
<dt>coerce</dt><dd><code>signature(from = "transactions", to = "data.frame")</code>; 
represents the set of transactions in a printable form 
as a data.frame. 
Note that this does not reverse coercion from data.frame 
to <code>transactions</code>.</dd>
<dt>labels</dt><dd><code>signature(x = "transactions")</code>;
returns the labels (item labels and transaction IDs) 
for the incidence matrix as a list of two vectors named <code>items</code>
and <code>transactionID</code>.</dd>
<dt>transactionInfo&lt;-</dt><dd><code>signature(x = "transactions")</code>;
replaces the transactionInfo data frame</dd>
<dt>transactionInfo</dt><dd><code>signature(x = "transactions")</code>;
returns transactionInfo</dd>
<dt>show</dt><dd><code>signature(object = "transactions")</code></dd>
<dt>summary</dt><dd><code>signature(object = "transactions")</code></dd>
</dl>

<h3>See Also</h3>

<p>
<code><a href="Xtrct-methods.html">[-methods</a></code>,
<code><a href="LIST.html">LIST</a></code>,
<code><a href="WRITE.html">WRITE</a></code>,
<code><a href="combine.html">c</a></code>,
<code><a href="image.html">image</a></code>,
<code><a href="inspect.html">inspect</a></code>,
<code><a href="read.transactions.html">read.transactions</a></code>,
<code><a href="random.transactions.html">random.transactions</a></code>,
<code><a href="sets.html">sets</a></code>,
<code><a href="itemMatrix-class.html">itemMatrix-class</a></code>
</p>


<h3>Examples</h3>

<pre>
## 1. example: creating transactions form a list
a_list &lt;- list(
      c("a","b","c"),
      c("a","b"),
      c("a","b","d"),
      c("c","e"),
      c("a","b","d","e")
      )

## set transaction names
names(a_list) &lt;- paste("Tr",c(1:5), sep = "")
a_list

## coerce into transactions
trans &lt;- as(a_list, "transactions")

## analyze transactions
summary(trans)
image(trans)

## 2. example: creating transactions from a matrix
a_matrix &lt;- matrix(
      c(1,1,1,0,0,
        1,1,0,0,0,
        1,1,0,1,0,
        0,0,1,0,1,
        1,1,0,1,1), ncol = 5)

## set dim names
dimnames(a_matrix) &lt;-  list(
        c("a","b","c","d","e"),
        paste("Tr",c(1:5), sep = ""))

a_matrix

## coerce
trans2 &lt;-  as(a_matrix, "transactions")
trans2

## example 3: creating transactions from data.frame
a_data.frame &lt;- data.frame(
        age = as.factor(c(6,8,7,6,9,5)), 
        grade = as.factor(c(1,3,1,1,4,1)))  
## note: all attributes have to be factors
a_data.frame

## coerce
trans3 &lt;- as(a_data.frame, "transactions") 
image(trans3)

## 3. example creating from data.frame with NA
a_df &lt;- sample(c(LETTERS[1:5], NA),10,TRUE)
a_df &lt;- data.frame(X = a_df, Y = sample(a_df))

a_df

trans3 &lt;- as(a_df, "transactions")
trans3
as(trans3, "data.frame")
</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 + -