zPatterns | R Documentation |
This function summarises the patterns of zero and/or missing values in a data set and returns a vector of pattern numbers.
zPatterns(X, label = NULL, plot = TRUE,
axis.labels = c("Component", "Pattern ID"),
bar.ordered = as.character(c(FALSE,FALSE)),
bar.colors = c("red3", "red3"), bar.labels = FALSE,
show.means = FALSE, round.means = 2, cex.means = 1,
type.means = c("cgm","am"),
cell.colors = c("dodgerblue", "white"),
cell.labels = c(label, paste("No", label)), cex.axis = 1.1,
grid.color = "black", grid.lty = "dotted",
legend = TRUE, suppress.print = FALSE, ...)
X |
Data set ( |
label |
Unique label ( |
plot |
Logical value indicating whether a graphical summary of the patterns is produced or not (default |
axis.labels |
Vector of axis labels for the table of patterns (format |
bar.ordered |
Vector of logical values to order table of patterns according to frequencies by patterns, component or both; with the first element referring to the patterns and the second to the components (default |
bar.colors |
Colors for the margin barplots (format |
bar.labels |
Logical value indicating if labels showing percentages must be added to the margin barplots (default |
show.means |
Logical value indicating if mean values by pattern are shown on the graphical summary table (default |
round.means |
When |
cex.means |
When |
type.means |
When |
cell.colors |
Vector of colors for the table cells (format |
cell.labels |
Labels for the cells (format |
cex.axis |
Axis labels scaling factor relative to default. |
grid.color |
Color of the grid lines (default |
grid.lty |
Style of the grid lines (default |
legend |
Logical value indicating if a legend must be included (default |
suppress.print |
Suppress printed feedback (default |
... |
Other graphical parameters. |
Vector (factor type) of pattern IDs corresponding to each row of X
.
By default, a summary table is printed showing patterns in the data according to label
and some summary statistics: number of zero/missing components by pattern (No.Unobs), pattern frequency in percentage, percentage zero/missing values by component (column) and overall percentage of zero/missing values in the data set. The symbols + and - indicate, respectively, zero/missing and observed components within each pattern. A graphical version of the summary table is returned including barplots on the margins displaying percentage zero/missing and compositional geometric means by pattern (if show.means=TRUE
; expressed in percentage scale). Common arithmetic means can be also shown for the case of ordinary data (type.means="am"
), however this is not recommended for compositional data.
The patterns are assigned ID number and by default arranged in the table in the same order as they are found in the data set. The argument bar.ordered
can be used to re-arrange the display according to frequencies of patterns, of unobserved values by component or both.
A warning message is shown if zeros or NA values not identified by label
are present in the data set. These will be ignored for the graphical display and numerical summaries of patterns, which will be only based on label
.
Check out 'plus' functions to deal with zeros and missing data simultaneously.
Palarea-Albaladejo J. and Martin-Fernandez JA. zCompositions – R package for multivariate imputation of left-censored data under a compositional approach. Chemometrics and Intelligence Laboratory Systems 2015; 143: 85-96.
lrEM
, lrEMplus
, lrDA
, multRepl
, multReplus
, multLN
, multKM
, cmultRepl
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)
# Show compositional geometric means (in %) per zero pattern
zPatterns(LPdata,label=0,show.means=TRUE)
# Same but orderer by pattern frequency and incidence of zeros by component
zPatterns(LPdata,label=0,bar.ordered=c(TRUE,TRUE),,bar.labels=TRUE,show.means=TRUE)
# Data set with zeros and missing data (0 = zero; NA = missing) (see lrEMplus function).
data(LPdataZM)
# Show missingness patterns only
zPatterns(LPdataZM,label=NA)
# Show zero patterns only and means by pattern based on available data
# (blanks indicate not enough data available for computation)
zPatterns(LPdataZM,label=0,show.means=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.