#' Prepare an analysis of missing data by computing their frequencies for each variable.
#' @param x Dataframe. Table containing the categorical variables to cross.
#' @param keypos Character vector. Names of the variables which should not be evaluated.
#' @return A tibble indicating the proportion of missing values per variable.
#' @importFrom tidyr gather
#' @importFrom dplyr mutate
#' @importFrom tibble as_tibble
#' @export
datexp_missing <- function(x,
keypos) {
#Bind variables
mising <- "missing"
variable <- "variable"
x <- as_tibble(x)
x <- gather(x, variable, missing, -keypos) %>%
mutate(missing = replace(missing, !is.na(missing), 0)) %>%
mutate(missing = replace(missing, is.na(missing), 1)) %>%
mutate(missing = as.numeric(missing))
return(x)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.