I need to run through a large data frame and extract a vector with the name of the variables that are numeric type.
I've got stuck in my code, perhaps someone could point me to a solution.
This is how far I have got:
numericVarNames <- function(df) {
    numeric_vars<-c()
    for (i in colnames(df)) {
        if (is.numeric(df[i])) {
            numeric_vars <- c(numeric_vars, colnames(df)[i])
            message(numeric_vars[i])
        }
    }
    return(numeric_vars)
}
To run it:
teste <-numericVarNames(semWellComb)
The is.numeric assertion is not working. There is something wrong with my syntax for catching the type of each column. What is wrong?