R/mice_imputation_factor_pmm_prepare.R

Defines functions mice_imputation_factor_pmm_prepare

## File Name: mice_imputation_factor_pmm_prepare.R
## File Version: 0.085

mice_imputation_factor_pmm_prepare <- function(y)
{
    is_factor <- FALSE
    y_aggr <- NULL
    y0 <- y
    if (is.factor(y)){
        y <- as.integer(y)
        y_aggr <- stats::aggregate(y, list(y0), mean)
        is_factor <- TRUE
        # y <- as.factor(y-1)
    }
    #--- output
    res <- list( is_factor=is_factor, y_aggr=y_aggr, y=y)
    return(res)
}

Try the miceadds package in your browser

Any scripts or data that you put into this service are public.

miceadds documentation built on May 29, 2024, 11:05 a.m.