A data frame contains 123 columns, and each columns have at least 1 NA value.
I want these NA values to be raplaced into column median. because there are so many columns, i cannot write a code using each column name.
so i tried to use 'apply' to solve this but it didn't work.
data2[-1]<-lapply(data2[-1],function(x)x - median(x,na.rm=TRUE))
it says it doesn't work since it is data frame, not numeric.