View source: R/e_plot_missing.R
e_plot_missing | R Documentation |
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,
sw_complete_by_variable = FALSE
)
dat_plot |
data.frame or tibble |
var_group |
variable name to group by (colors data) |
sw_group_sort |
TRUE/FALSE to sort by grouped variable |
var2_sort |
second variable name to sort by if data is grouped |
sw_title_data_name |
TRUE/FALSE to include data object name in title or text string of title to use |
sw_text_pct_miss |
TRUE/FALSE to include text values of percent missing on bar plot |
sw_complete_by_variable |
TRUE/FALSE to run |
ggplot grob plot object
# Generate missing values
dat_mtcars_miss_e <- dat_mtcars_e
prop_missing <- 0.10
n_missing <-
sample.int(
n = prod(dim(dat_mtcars_miss_e))
, size = round( prop_missing * prod(dim(dat_mtcars_miss_e)))
)
ind_missing <- expand.grid(1:dim(dat_mtcars_miss_e)[1], 1:dim(dat_mtcars_miss_e)[2])[n_missing, ]
for (i_row in seq_along(n_missing)) {
dat_mtcars_miss_e[ind_missing[i_row, 1], ind_missing[i_row, 2] ] <- NA
}
e_plot_missing(
dat_plot = dat_mtcars_miss_e
, var_group = "cyl"
, sw_group_sort = TRUE
, var2_sort = "disp"
)
e_plot_missing(
dat_plot = dat_mtcars_miss_e
, var_group = "cyl"
, sw_group_sort = TRUE
, var2_sort = "disp"
, sw_title_data_name = "mtcars with random missing values"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.