<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Finds within class correlations</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="R.css" />
</head><body>

<table width="100%" summary="page for cor.by.class"><tr><td>cor.by.class</td><td style="text-align: right;">R Documentation</td></tr></table>

<h2>
Finds within class correlations
</h2>

<h3>Description</h3>

<p>Finds within class correlations between samples of each class type,  which is useful for identifying extreme observations and assessing whether CCM is appropriate for classification.
</p>


<h3>Usage</h3>

<pre>
cor.by.class(x, y, method = "pearson", use = "complete")
</pre>


<h3>Arguments</h3>

<table summary="R argblock">
<tr valign="top"><td><code>x</code></td>
<td>

<p>data matrix with variables in rows and samples in columns
</p>
</td></tr>
<tr valign="top"><td><code>y</code></td>
<td>

<p>classes corresponding to the columns of <code>x</code>
</p>
</td></tr>
<tr valign="top"><td><code>method</code></td>
<td>

<p>the type of correlation to use, either 'pearson' (the default) or 'spearman'
</p>
</td></tr>
<tr valign="top"><td><code>use</code></td>
<td>

<p>instructions for handling missing values. See details and <code>cor</code>. All values are used by default.
</p>
</td></tr>
</table>


<h3>Details</h3>

<p>Calculates correlations between each pair of observations within each class. The correlation between an observation and itself is ignored.
</p>
<p>The default correlation is the Pearson product moment correlation. If <code>method</code> is 'spearman', then the Spearman's rank correlation is used, which is the Pearson correlation calculated using the ranks of the data.
</p>
<p>Correlations are calculated class-wise on the matrix of observations of each class separately. Therefore, missing values may be handled differently for different classes.
</p>


<h3>Value</h3>

<p>A list with each element a vector of correlations between samples of a different class.
</p>


<h3>Author(s)</h3>

<p>Garrett M. Dancik and Yuanbin Ru
</p>


<h3>Examples</h3>

<pre>
data(data.expr)
data(data.gender)
K = cor.by.class(data.expr, data.gender)
## visualize the results ##
boxplot(K, xlab = "gender")
</pre>


</body></html>
