gclus (version 1.3.2)

dmat.color: Colors a symmetric matrix

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

dmat.color(m, colors = default.dmat.color, byrank = NULL, breaks = length(colors))

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.

Value

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

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.

See Also

cut, cpairs, cparcoord

Examples

Run this code
# NOT RUN {
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)

# }

Run the code above in your browser using DataCamp Workspace