Isi data NA dalam nilai rata -rata di r

for(i in 1:ncol(data)){
  data[is.na(data[,i]), i] <- mean(data[,i], na.rm = TRUE)
}
SHUO ZHANG