Learn R Programming

VIM (version 3.0.2)

matrixplot: Matrix plot

Description

Create a matrix plot, in which all cells of a data matrix are visualized by rectangles. Available data is coded according to a continuous color scheme, while missing/imputed data is visualized by a clearly distinguishable color.

Usage

matrixplot(x, delimiter = NULL, sortby = NULL, col = c("red","orange"),
    gamma = 2.2, fixup = TRUE, xlim = NULL, ylim = NULL, main = NULL,
    sub = NULL, xlab = NULL, ylab = NULL, axes = TRUE, labels = axes,
    xpd = NULL, interactive = TRUE, ...)

TKRmatrixplot(x, ..., delimiter = NULL, hscale = NULL, vscale = NULL, TKRpar = list())

iimagMiss(x, delimiter = NULL, sortby = NULL, col = c("red","orange"), main = NULL, sub = NULL, xlab = NULL, ylab = NULL, xlim = NULL, ylim = NULL, axes = TRUE, xaxlabels = NULL, las = 3, interactive = TRUE, ...)

Arguments

x
a matrix or data.frame.
delimiter
a character-vector to distinguish between variables and imputation-indices for imputed variables (therefore, x needs to have colnames). If given, it is used to determine the cor
sortby
a numeric or character value specifying the variable to sort the data matrix by, or NULL to plot without sorting.
col
the colors to be used in the plot. RGB colors may be specified as character strings or as objects of class "RGB". HCL colors need to be specified as objects of class "
gamma
numeric; the display gamma value (see hex).
fixup
a logical indicating whether the colors should be corrected to valid RGB values (see hex).
xlim, ylim
axis limits.
main, sub
main and sub title.
xlab, ylab
axis labels.
axes
a logical indicating whether axes should be drawn on the plot.
labels
either a logical indicating whether labels should be plotted below each column, or a character vector giving the labels.
xpd
a logical indicating whether the rectangles should be allowed to go outside the plot region. If NULL, it defaults to TRUE unless axis limits are specified.
interactive
a logical indicating whether a variable to be used for sorting can be selected interactively (see Details).
xaxlabels
a character vector containing the labels for the columns. If NULL, the column names of x will be used.
las
the style of axis labels (see par).
...
for matrixplot and iimagMiss, further graphical parameters to be passed to plot.window, title and
hscale
horizontal scale factor for plot to be embedded in a Tcl/Tk window (see Details). The default value depends on the number of variables.
vscale
vertical scale factor for the plot to be embedded in a Tcl/Tk window (see Details). The default value depends on the number of observations.
TKRpar
a list of graphical parameters to be set for the plot to be embedded in a Tcl/Tk window (see Details and par).

Details

In a matrix plot, all cells of a data matrix are visualized by rectangles. Available data is coded according to a continuous color scheme. To compute the colors via interpolation, the variables are first scaled to the interval $$[0,1]$$. Missing/imputed values can then be visualized by a clearly distinguishable color. It is thereby possible to use colors in the HCL or RGB color space. A simple way of visualizing the magnitude of the available data is to apply a greyscale, which has the advantage that missing/imputed values can easily be distinguished by using a color such as red/orange. Note that -Inf and Inf are always assigned the begin and end color, respectively, of the continuous color scheme. Additionally, the observations can be sorted by the magnitude of a selected variable. If interactive is TRUE, clicking in a column redraws the plot with observations sorted by the corresponding variable. Clicking anywhere outside the plot region quits the interactive session. TKRmatrixplot behaves like matrixplot, but uses tkrplot to embed the plot in a Tcl/Tk window. This is useful if the number of observations and/or variables is large, because scrollbars allow to move from one part of the plot to another.

References

M. Templ, A. Alfons, P. Filzmoser (2012) Exploring incomplete data using visualization tools. Journal of Advances in Data Analysis and Classification, Online first. DOI: 10.1007/s11634-011-0102-y.

Examples

Run this code
data(sleep, package = "VIM")
## for missing values
x <- sleep[, -(8:10)]
x[,c(1,2,4,6,7)] <- log10(x[,c(1,2,4,6,7)])
matrixplot(x, sortby = "BrainWgt")

## for imputed values
x_imp <- kNN(sleep[, -(8:10)])
x_imp[,c(1,2,4,6,7)] <- log10(x_imp[,c(1,2,4,6,7)])
matrixplot(x_imp, delimiter = "_imp", sortby = "BrainWgt")

Run the code above in your browser using DataLab