R: Plotting Logical Matrices

clmplot {cba} | R Documentation

## Plotting Logical Matrices

### Description

A wrapper function to `image` that produces a level plot with the option to color the rows (or columns) based on a clustering and/or classification of the data, and the option to reorder the rows and columns for better presentation.

### Usage

    clmplot(x, col, col.bycol = FALSE, order=FALSE,
            dist.method = "binary", hclust.method = "average",
            axes = FALSE, xlab = "", ylab = "", ...)

### Arguments

`x` | an logical matrix.
`col` | an optional vector defining a coloring.
`col.bycol` | option to color by columns.
`order` | option to (pre)order the rows and columns.
`dist.method` | method to be used by `dist`.
`hclust.method` | method to be used by `hclust`.
`axes` | option to plot axes.
`xlab, ylab` | labels for the x and y axis.
`...` | further arguments to `image`.

### Details

For dummy coded data the level `FALSE` is assumed to carry no information and is colored `white`. Thus, the level `TRUE` can be colored according to some classification of the rows (or columns) of the data matrix. If no color specification is supplied the default color `black` is used.

If `col` is of type character it is assumed to contain color codes. Otherwise, it must be a factor and the levels are assigned colors from `heat.colors`.

If `order` is `TRUE` the rows and columns are ordered by `hclust` where the distances are computed by `dist`.

Note that an axis is only plotted if the number of elements (rows or columns) is less than 100.

### Value

A list with the following components:

`rows` | the row order.
`cols` | the column order.

### Author(s)

Christian Buchta

### See Also

`lmplot` for plotting of logical data at reduced resolutions, `heatmap` for ordered plotting of real-valued data, and package gclus for ordering functions.

### Examples

    x <- matrix(sample(c(FALSE,TRUE),100,rep=TRUE),ncol=10)
    clmplot(x, order=TRUE, axes=TRUE)
    clmplot(x, col=rep(c(1,2),each=5))
    clmplot(x, col=rep(c("red","blue"),each=5))
    clmplot(x, col=rep(c("red","blue"),each=5), col.bycol=TRUE)
    ## Not run:
    ### continue example (see rockCluster)
    col <- Votes$Class                                  # color by party
    levels(col) <- c("red","blue")
    op <- par(mfrow=c(1,2), pty="s")
    clmplot(x, order=TRUE, col=as.character(col), main="Parties")
    col <- rf$cl                                        # color by cluster
    levels(col) <- c("blue","red","green", "black")     # map NA to black
    clmplot(x, order=TRUE, col=as.character(col), main="Clusters")
    par(op)

    ## End(Not run)

[Package cba version 0.2-21 Index]