Learn R Programming

ForImp (version 1.0.3)

medianimp: Median imputation

Description

Median imputation

Usage

medianimp(mat)

Arguments

mat
A matrix of ordinal values , ordered according to the Likert scale (1, 2, 3,...)

Value

The imputed matrix

Details

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

See Also

modeimp, meanimp

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
medianimp(matm)
# original matrix with no missing values
mat

Run the code above in your browser using DataLab