Random generation of missing values

Share:

Description

Random generation of missing values in matrices

Usage

1

Arguments

mat

a matrix (n rows, m columns)

missing

a vector: element i contains the desired number of rows with i missing values (1<=i<=m)

Value

a matrix with the specified pattern of missing values

Author(s)

Alessandro Barbiero, Giancarlo Manzi, Pier Alda Ferrari

See Also

missingmat,missingness

Examples

1
2
3
4
5
6
7
8
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)