Retrieving variable names for numeric variables
<p>I need to run through a large data frame and extract a vector with the name of the variables that are numeric type.</p>

<p>I've got stuck in my code, perhaps someone could point me to a solution.</p>

<p>This is how far I have got:</p>

<pre><code>numericVarNames &lt;- function(df) {
    numeric_vars&lt;-c()
    for (i in colnames(df)) {
        if (is.numeric(df[i])) {
            numeric_vars &lt;- c(numeric_vars, colnames(df)[i])
            message(numeric_vars[i])
        }
    }
    return(numeric_vars)
}
</code></pre>

<p>To run it:</p>

<pre><code>teste &lt;-numericVarNames(semWellComb)
</code></pre>

<p>The is.numeric assertion is not working. There is something wrong with my syntax for catching the type of each column. What is wrong?</p>