R/prodNA.R

Defines functions prodNA

Documented in prodNA

##
## MissForest - nonparametric missing value imputation for mixed-type data
##
## This R script contains the function to produce missing values in a given
## data set completely at random.
##
## Author: D.Stekhoven, stekhoven@stat.math.ethz.ch
##############################################################################

prodNA <- function(x, noNA = 0.1){
  n <- nrow(x)
  p <- ncol(x)
  NAloc <- rep(FALSE, n*p)
  NAloc[sample(n * p, floor(n * p * noNA))] <- TRUE
  x[matrix(NAloc, nrow = n, ncol = p)] <- NA
  return(x)
}

Try the missForest package in your browser

Any scripts or data that you put into this service are public.

missForest documentation built on April 14, 2022, 5:05 p.m.