Nothing
#' Summarize missing values by column or row
#'
#' @param data A data.frame.
#' @param margin Summarize missingness `"column"`-wise (the default) or
#' `"row"`-wise.
#'
#' @return A basetable with one row per column (or per row) describing the count
#' and proportion of missing values.
#' @export
missingness <- function(data, margin = c("column", "row")) {
margin <- match.arg(margin)
df <- bt_as_data_frame(data)
if (margin == "column") {
return(bt_as_data_table(data.frame(
column = names(df),
missing = vapply(df, function(x) sum(bt_is_blank(x)), numeric(1)),
missing_prop = vapply(df, function(x) mean(bt_is_blank(x)), numeric(1)),
complete = vapply(df, function(x) sum(!bt_is_blank(x)), numeric(1)),
stringsAsFactors = FALSE
)))
}
miss_mat <- do.call(cbind, lapply(df, bt_is_blank))
bt_as_data_table(data.frame(
row = seq_len(nrow(df)),
missing = rowSums(miss_mat),
complete = rowSums(miss_mat) == 0L,
stringsAsFactors = FALSE
))
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.