I've read all the threads related to my question (i'm pretty sure i did).
I have written a function that automatically check for the class of the variable if it is numeric then proceeds to replace the NAs with the mean of those variables.
Here's the code :
delna<-function(x){
for (e in 1:ncol(x)){
if (class(x[,e])=="numeric"){
for (e in 1:ncol(x)) {
x[is.na(x[,e]),e]<-mean(x[,e],na.rm = TRUE)
}}
}
}
I get no result when validating the function and when using it on a data frame i get warnings saying :
"In mean.default(x[, e], na.rm = TRUE) : argument is not numeric or logical: returning NA"
Thank you for your help everyone !