R/imputeRough.R

Defines functions imputeRough

Documented in imputeRough

imputeRough <- function(data, Init = "mean") {
  Pre <- my.dummy.df(data)
  if(Init == "mean") {
    output <- as.data.frame(apply(Pre, 2, function(x) ifelse(is.na(x), mean(x, na.rm = TRUE), x)))
  } else {
    output <- as.data.frame(apply(Pre, 2, function(x) ifelse(is.na(x), median(x, na.rm = TRUE), x)))
  }
  Preds <- output[sapply(Pre, function(x) is.na(x))]
  list(Initials = Preds, Pre.Imputed = Pre, Imputed.Dataframe = output)
}

Try the mvdalab package in your browser

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

mvdalab documentation built on Oct. 6, 2022, 1:05 a.m.