Learn R Programming

ForImp (version 1.0.3)

modeimp: Mode imputation

Description

Mode imputation

Usage

modeimp(mat)

Arguments

mat
A matrix of categorical or ordinal values, coded as integer values (1, 2, 3, ...)

Value

The imputed matrix

Details

The function implements the mode imputation on a matrix of categorical or ordinal data with missing values. The function substitutes to each missing value the mode of the corresponding variable.

See Also

medianimp, modeimp

Examples

Run this code
set.seed(1)
n<-10
m<-3
mat<-matrix(ceiling(runif(n*m)*4),n,m)
matm<-mat
matm[1,3]<-NA
matm[9:10,1]<-NA
# matrix with missing values
matm
# imputed matrix
modeimp(mat)
# original matrix with no missing values
mat

Run the code above in your browser using DataLab