Takes a vector, matrix or data.frame
and replaces some values by NA
.
Examples
generateNA(1:10, p = 0.5)
#> [1] 1 2 3 NA NA NA NA 8 9 NA
head(generateNA(iris, p = 0.2))
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1 NA 3.5 1.4 0.2 setosa
#> 2 4.9 NA 1.4 0.2 <NA>
#> 3 4.7 3.2 1.3 NA <NA>
#> 4 NA 3.1 NA 0.2 setosa
#> 5 NA NA 1.4 0.2 setosa
#> 6 5.4 3.9 1.7 0.4 setosa