title: How to index data frame column by a variable?
body: <p>As an example, I want a function that will iterate over the columns in a dataframe and print out each column's data type (e.g., "numeric", "integer", "character", etc)</p>
  
  <p>Without a variable I know I can do <code>class(df$MyColumn)</code> and get the data type.  How can I change it so "MyColumn" is a variable?</p>
  
  <p>What I'm trying is</p>
  
  <pre><code>f &lt;- function(df) {
  
   for(column in names(df)) {
     columnClass = class(df[column])
     print(columnClass)
   }
  
  }
  </code></pre>
  
  <p>But this just prints out <code>[1] "data.frame"</code> for each column.</p>