The function implements the unconditional mean imputation on a numerical matrix with missing values, substituting to each missing value the arithmetic mean of the corresponding variable
set.seed(1)
n<-10m<-3mat<-matrix(rnorm(n*m),n,m)
matm<-mat
matm[1,1]<-NAmatm[2,2:3]<-NA# matrix with missing valuesmatm
# imputed matrixmeanimp(mat)
# original matrix with no missing valuesmat