tablemissing | R Documentation |
Tabulates missing values in variables and patterns of missing values among variables. It produces a missing value plot displaying different patterns of missing values among variables and missing value counts.
tablemissing(
x,
sortby = "variable",
bot = 6,
mar = c(bot, 1, 1.5, 1),
adj = c(0, -0.1),
xpd = TRUE,
srt = -60,
cex = 0.8,
zoom = FALSE,
...
)
x |
the dataset to be examined. It should be of class matrix or dataframe. |
sortby |
a logical value indicating whether the variables, patterns or both are sorted by the numbers of missing values. Possible values are "variable" (sort by variable name), "row" (sort by pattern counts), "column" (sort by variable counts) and "both" (sort by variable and pattern counts). |
This function tabulates the missing values in variables and the patterns of missings. The input data should be of class matrix or dataframe. The function also displays a missing value plot. Each row represents a pattern of missings, where the variables with missing values are shown in yellow. The barchart below shows the proportions of missing values by variable. The barchart on the right displays the pattern frequencies. This barchart uses the concept of censored zooming. The topmost bar, representing no missing values in any variable, is likely to be much larger than the others and will then not be drawn to scale, but bordered in red to show this. Ordering of variables and patterns of missings based on counts can be very useful for exploring the structure of missings in a dataset.
finaltable |
A table of class dataframe containing number of missing values in variable and missing pattern |
Waqas Ahmed Malik, with small modifications.
## Not run:
data(hs)
zz <- hs
missings <- cbind(sample(1:50, 100, replace = T), sample(2:6, 100, replace = T))
missings <- unique(missings)
nrow(missings)
dim(missings)
zz[missings] <- rep(NA, nrow(missings))
tablemissing(zz, sortby = "variable")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.