#' Majority voting
#'
#' The function for providing majority voting function after MICE imputation
#'
#' This function is used to peform majority voting on data generated by MICE imputation
#'
#' @author Shoji F. Nakayama
#'
#' @param v data
#'
#' @examples
#' \dontrun{
#' require(tidyverse)
#' require(miceRanger)
#' require(doParallel)
#'
#' set.seed(9973)
#'
#' # Load data
#' data(iris)
#'
#' # Ampute the data. iris contains no missing values by default.
#' ampIris <- amputeData(iris, perc = 0.25)
#' head(ampIris, 10)
#' summary(ampIris)
#'
#' # Set up back ends.
#' cl <- makeCluster(2)
#' registerDoParallel(cl)
#'
#' # Perform mice
#' miceObjPar <- miceRanger(
#' ampIris,
#' m = 6,
#' parallel = TRUE,
#' verbose = FALSE
#' )
#' stopCluster(cl)
#' registerDoSEQ()
#'
#' imp <- completeData(miceObjPar)
#' imp <- tidyMice(imp)
#' df.imp <- imp %>% group_by(.id) %>% summarise_at(.vars = names(.)[3:ncol(imp)], .funs = 'mjvote')
#' df.imp <- df.imp[, -1]
#'
#' summary(df.imp)
#' }
#'
#' @export
#'
#'
mjvote <- function(v) {
uniqv <- unique(v)
uniqv[which.max(tabulate(match(v, uniqv)))]
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.