title: Get the column number in R given the column name
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4427234/get-column-index-from-label-in-a-data-frame">Get column index from label in a data frame</a>  </p>
  </blockquote>
  
  
  
  <p>I need to get the column number of a column given its name.</p>
  
  <p>Supose we have the following dataframe:</p>
  
  <pre><code>df &lt;- data.frame(a=rnorm(100),b=rnorm(100),c=rnorm(100))
  </code></pre>
  
  <p>I need a function that would work like the following:</p>
  
  <pre><code>getColumnNumber(df,"b")
  </code></pre>
  
  <p>And it would return </p>
  
  <pre><code>[1] 2
  </code></pre>
  
  <p>Is there a function like that?</p>
  
  <p>Thanks!</p>