Learn R Programming

CCM (version 1.2)

cor.by.class: Finds within class correlations

Description

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.

Usage

cor.by.class(x, y, method = "pearson", use = "complete")

Arguments

x

data matrix with variables in rows and samples in columns

y

classes corresponding to the columns of x

method

the type of correlation to use, either 'pearson' (the default) or 'spearman'

use

instructions for handling missing values. See details and cor. All values are used by default.

Value

A list with each element a vector of correlations between samples of a different class.

Details

Calculates correlations between each pair of observations within each class. The correlation between an observation and itself is ignored.

The default correlation is the Pearson product moment correlation. If method is 'spearman', then the Spearman's rank correlation is used, which is the Pearson correlation calculated using the ranks of the data.

Correlations are calculated class-wise on the matrix of observations of each class separately. Therefore, missing values may be handled differently for different classes.

Examples

Run this code
# NOT RUN {
data(data.expr)
data(data.gender)
K = cor.by.class(data.expr, data.gender)
## visualize the results ##
boxplot(K, xlab = "gender")
# }

Run the code above in your browser using DataLab