dmat.color: Colors a symmetric matrix

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/graphclus.R

Description

Accepts a dissimilarity matrix or dist m, and returns a matrix of colors. Values in m are cut into categories using breaks (ranked distances if byrank is TRUE) and categories are assigned the values in colors.

Usage

1

Arguments

m

a dissimilarity matrix or the result of dist

colors

a vector of colors. The default is default.dmat.color.

byrank

boolean, default TRUE is unless breaks has length > 1.

breaks

the number of break points.

Details

breaks are passed to the functioncut. If byrank is TRUE, values in m are ranked before they are categorized. If byrank is TRUE and breaks is an integer, then there are breaks equal-sized categories.

Value

Returns a matrix of colors. The matrix is symmetric, with NAs on the diagonal.

Author(s)

Catherine B. Hurley

See Also

cut, cpairs, cparcoord

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
data(longley)
longley.cor <- cor(longley)
# A matrix with equal (or nearly equal) number of entries of each color.
longley.color <- dmat.color(longley.cor)

# Plot the colors
plotcolors(longley.color,dlabels=rownames(longley.color))

# Try different color schemes

# A matrix where each color represents an equal-length interval.
longley.color <- dmat.color(longley.cor, byrank=FALSE)
# Specify colors and breaks

longley.color <- dmat.color(longley.cor, breaks=c(-1,0,.5,.8,1), 
cm.colors(4))


# Could also reorder variables prior to plotting:

longley.o <- order.single(longley.cor)
longley.color <- longley.color[longley.o,longley.o]

# The colors can be used in a scatterplot matrix or parallel
# coordinate display:

cpairs(longley, panel.color= longley.color)
cparcoord(longley, panel.color= longley.color)

gclus documentation built on May 2, 2019, 5:08 a.m.