Last data update: 2014.03.03

R: Find and display patterns of zeros or unobserved values in a...
zPatternsR Documentation

Find and display patterns of zeros or unobserved values in a data set

Description

This function summarises the patterns of zero or unobserved values in a data set and returns a vector of pattern numbers.

Usage

zPatterns(X, label = NULL, plot = TRUE,
             axis.labels = c("Component", "Pattern number"),
             bar.colors = c("red3", "red3"), bar.labels = FALSE,
             cell.colors = c("dodgerblue", "white"),
             cell.labels = c(label, paste("No", label)), cex.axis = 1.1,
             grid.color = "black", grid.lty = "dotted", legend = TRUE, ...)

Arguments

X

Data set (matrix or data.frame class).

label

Unique label (numeric or character) used to denote zero or unobserved values in X.

plot

Logical value indicating whether a graphical summary of the patterns is produced or not (default plot=TRUE).

axis.labels

Vector of axis labels for the table of patterns (format c("x-axis","y-axis")).

bar.colors

Colors for the margin barplots (format c("col.top","col.right")).

bar.labels

Logical value indicating if labels showing percentages must be added to the margin barplots (default bar.labels=FALSE).

cell.colors

Vector of colors for the table cells (format c("col.unobserved","col.observed")).

cell.labels

Labels for the cells (format c("Unobserved","Observed"), default c(label,paste("No",label))).

cex.axis

Axis labels scaling factor relative to default.

grid.color

Color of the grid lines (default "black").

grid.lty

Style of the grid lines (default "dotted", see lty in par).

legend

Logical value indicating if a legend must be included (default legend=TRUE).

...

Other graphical parameters.

Value

Vector of pattern IDs corresponding to each row of X.

It also prints a summary table showing zero or non-observation patterns and some summary statistics: number of zero/unobserved components by pattern (No.Unobs), pattern frequency (absolute and percentage), percentage zero/unobserved values by component (column) and overall percentage of zero/unobserved values in the data set. The symbols + and - indicate, respectively, zero/unobserved and observed components within each pattern. A graphical version of the summary table is returned including barplots on the margins displaying percentage zero/unobserved values by component (top) and percentage occurrence of the patterns in the data set (right).

See Also

lrEM, lrDA, multRepl, multLN, multKM, cmultRepl

Examples

data(LPdata)

pattern.ID <- zPatterns(LPdata,label=0)

LPdata[pattern.ID==5,]
LPdata[pattern.ID==7,]
LPdata[pattern.ID==10,]

# Modify cell labels and show percentages along with barplots
pattern.ID <- zPatterns(LPdata,label=0,
              cell.labels=c("Zero","Non-zero"),bar.labels=TRUE)

Results