I am trying to do a series of function but selecting between two variables. I need to first impute the missing values then normalize the variables. To impute I use the following code.
for(i in (train$B365A:train$BSA)){
data[i][is.na(data[i])] <- round(mean(data[i], na.rm = TRUE))
}
so for above, I am trying to impute the missing values, they have approximately 20 variables between them.
I have come up with this but it is not affecting the cells.
convert_num <- function(i) {
i <- as.numeric(i)
}
for (i in c(1:3)){
convert_num(i)
}
The data looks similar to the following hope coal kite 3 4 5 2 1 5 right now its class but need to be numeric.It has over 20 variables and 18k row.