Learn R Programming

ForImp (version 1.0.3)

missingmat2: Random generation of missing values

Description

Random generation of missing values in matrices

Usage

missingmat2(mat, missing)

Arguments

mat
a matrix (n rows, m columns)
missing
a vector: element i contains the desired number of rows with i missing values (1

Value

a matrix with the specified pattern of missing values

See Also

missingmat,missingness

Examples

Run this code
mat<-matrix(rnorm(500),100,5)
# if you want 20 rows with 1 missing, 10 rows with 2 missing,
# 4 rows with 3 missing, 1 row with 4 missing
missing<-c(20,10,4,1)
matm<-missingmat2(mat, missing)
matm
# check that the function works
missingness(matm)

Run the code above in your browser using DataLab