itemcoding.html
来自「本程序是基于linux系统下c++代码」· HTML 代码 · 共 150 行
HTML
150 行
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>R: Item Coding – Handling Item Labels and Column IDs Conversions</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 itemCoding {arules}"><tr><td>itemCoding {arules}</td><td align="right">R Documentation</td></tr></table>
<h2>Item Coding – Handling Item Labels and Column IDs Conversions</h2>
<h3>Description</h3>
<p>
Provides the generic functions and the S4 methods for converting item labels
into column IDs used in the binary matrix representation and vice versa.
</p>
<p>
<code>decode</code> converts from the numeric (column IDs) representation to
readable item labels. <code>decode</code> is used by <code><a href="LIST.html">LIST</a></code>.
</p>
<p>
<code>encode</code> converts from readable item labels to an itemMatrix using a
given coding. With this method it is possible to create several compatible
<code>itemMatrix</code> objects (i.e., use the same binary representation for
items) from data.
</p>
<p>
<code>recode</code> recodes an <code>itemMatrix</code> object so its coding is compatible
with another object.
</p>
<h3>Usage</h3>
<pre>
decode(x, ...)
## S4 method for signature 'list':
decode(x, itemLabels)
## S4 method for signature 'numeric':
decode(x, itemLabels)
encode(x, ...)
## S4 method for signature 'list':
encode(x, itemLabels, itemMatrix = TRUE)
## S4 method for signature 'character':
encode(x, itemLabels, itemMatrix = TRUE)
## S4 method for signature 'numeric':
encode(x, itemLabels, itemMatrix = TRUE)
recode(x, ...)
## S4 method for signature 'itemMatrix':
recode(x, itemLabels = NULL, match = NULL)
</pre>
<h3>Arguments</h3>
<table summary="R argblock">
<tr valign="top"><td><code>x</code></td>
<td>
a vector or a list of vectors of character strings
(for <code>encode</code>) or of numeric (for <code>decode</code>), or
an object of class <code>itemMatrix</code> (for <code>recode</code>).</td></tr>
<tr valign="top"><td><code>itemLabels</code></td>
<td>
a vector of character strings used for coding where
the position of an item label in the vector gives the item's column ID.
The used <code>itemLabels</code> vector can be obtained from <code>itemMatrix</code>,
<code>transactions</code> and <code>associations</code> by the
method <code>itemLabels</code>.</td></tr>
<tr valign="top"><td><code>itemMatrix</code></td>
<td>
return an object of class <code>itemMatrix</code> otherwise
an object of the same class as <code>x</code> is returned.</td></tr>
<tr valign="top"><td><code>match</code></td>
<td>
an <code>itemMatrix</code> object whose item coding <code>x</code>
should match.</td></tr>
<tr valign="top"><td><code>...</code></td>
<td>
further arguments.</td></tr>
</table>
<h3>Value</h3>
<p>
<code>recode</code> always returns an object
of class <code>itemMatrix</code>.
<br>
For <code>encode</code> with <code>itemMatrix = TRUE</code> an object
of class <code>itemMatrix</code> is returned.
Otherwise the result is of the same type as <code>x</code>, e.g., a
list or a vector.</p>
<h3>See Also</h3>
<p>
<code><a href="LIST.html">LIST</a></code>,
<code><a href="associations-class.html">associations-class</a></code>,
<code><a href="itemMatrix-class.html">itemMatrix-class</a></code>
</p>
<h3>Examples</h3>
<pre>
data("Adult")
## Example 1: Manual decoding
## get code
iLabels <- itemLabels(Adult)
head(iLabels)
## get undecoded list and decode in a second step
list <- LIST(Adult[1:5], decode = FALSE)
list
decode(list, itemLabels = iLabels)
## Example 2: Manually create an itemMatrix
data <- list(
c("income=small", "age=Young"),
c("income=large", "age=Middle-aged")
)
iM <- encode(data, iLabels)
iM
inspect(iM)
## use the itemMatrix to create transactions
as(iM, "transactions")
## Example 3: use recode
## select first 100 transactions and all education-related items
sub <- Adult[1:100, itemInfo(Adult)$variables == "education"]
itemLabels(sub)
image(sub)
## recode to match Adult again
sub.recoded <- recode(sub, match = Adult)
image(sub.recoded)
</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 + =
减小字号Ctrl + -
显示快捷键?