R/removeNA.R

Defines functions removeNA

#' @export
removeNA <- function(x) { 
  # calculate proportion of NA
  numNA <- length(x[is.na(x)]) / length(x)
  
  if(numNA > .05)
    warning(paste0("NAs are ", round(numNA*100, 2), "% of the data.\n"))
  
  x[is.na(x)] <- mean(x, na.rm=T)
  return(x) 
}
ccamp83/mu documentation built on Sept. 10, 2023, 4:22 p.m.