clPairs: Pairwise Scatter Plots showing Classification
Description
Creates a scatter plot for each pair of variables in given data.
Observations in different classes are represented by different colors and symbols.Usage
clPairs(data, classification, symbols, colors, labels = dimnames(data)[[2]],
CEX = 1, gap = 0.2, ...)clPairsLegend(x, y, class, col, pch, ...)
Arguments
data
A numeric vector, matrix, or data frame of observations. Categorical
variables are not allowed. If a matrix or data frame, rows
correspond to observations and columns correspond to variables.
classification
A numeric or character vector representing a classification of observations
(rows) of data.
symbols
Either an integer or character vector assigning a plotting symbol to each
unique class in classification. Elements in symbols
correspond to classes in order of appearance in the sequence of
observations (the order use
colors
Either an integer or character vector assigning a color to each
unique class in classification. Elements in colors
correspond to classes in order of appearance in the sequence of
observations (the order used by the fu
labels
A vector of character strings for labeling the variables. The default
is to use the column dimension names of data.
CEX
An argument specifying the size of the plotting symbols.
The default value is 1.
gap
An argument specifying the distance between subplots (see pairs). x,y
The x and y co-ordinates with respect to a graphic device having
plotting region coordinates par("usr" = c(0,1,0,1)).
col, pch
The colors and plotting symbols appearing in the legend.
...
For a clPairs call may be additional arguments to be passed to pairs.
For a clPairsLegend call may be additional arguments to be passed to l Value
- The function
clPairs invisibly returns a list with the following
components: - classA character vector of class labels.
- colA vector of colors used for each class.
- pchA vector of plotting symbols used for each class.
Details
The function clPairs draws scatter plots on the current graphics
device for each combination of variables in data. Observations of
different classifications are labeled with different symbols.
The function clPairsLegend can be used to add a legend. See examples
below.References
C. Fraley, A. E. Raftery, T. B. Murphy and L. Scrucca (2012).
mclust Version 4 for R: Normal Mixture Modeling for Model-Based
Clustering, Classification, and Density Estimation.
Technical Report No. 597, Department of Statistics, University of Washington.Examples
Run this codeclPairs(iris[,1:4], cl = iris$Species)
clp <- clPairs(iris[,1:4], cl = iris$Species, lower.panel = NULL)
clPairsLegend(0.1, 0.4, class = clp$class,
col = clp$col, pch = clp$pch,
title = "Iris data")
Run the code above in your browser using DataLab