R/e_plot_missing.R
e_plot_missing.Rd
Plots missing data in a data.frame, possibly grouped by one variable and sorted by a second.
e_plot_missing(
dat_plot,
var_group = NULL,
sw_group_sort = FALSE,
var2_sort = NULL,
sw_title_data_name = TRUE,
sw_text_pct_miss = FALSE
)
data.frame or tibble
variable name to group by (colors data)
TRUE/FALSE to sort by grouped variable
second variable name to sort by if data is grouped
TRUE/FALSE to include data object name in title
TRUE/FALSE to include text values of percent missing on bar plot
ggplot grob plot object
dat_miss = dat_mtcars_e
prop_missing = 0.10
n_missing = sample.int(n = prod(dim(dat_miss)), size = round( prop_missing * prod(dim(dat_miss))))
ind_missing = expand.grid(1:dim(dat_miss)[1], 1:dim(dat_miss)[2])[n_missing, ]
for (i_row in seq_along(n_missing)) {
dat_miss[ind_missing[i_row,1], ind_missing[i_row,2] ] <- NA
}
e_plot_missing(
dat_plot = dat_miss
, var_group = "cyl"
, sw_group_sort = TRUE
, var2_sort = "disp"
)
#> Warning: Using alpha for a discrete variable is not advised.