title: R programming: which(colnames(df) == "thecolumnname") is not working inside a function?
body: <p>I have a function:</p>
  
  <pre><code>findcolnumber &lt;- function(df, thecolumnname){
  which(colnames(df) == "thecolumnname")
  }
  </code></pre>
  
  <p>And I would like to be able to find the column number by giving the 2 arguments to the function.</p>
  
  <p>Example arguments: data, columnX</p>
  
  <pre><code>which(colnames(data) == "columnX")    #This works properly
  
  findcolnumber(data, columnX)    #This does not work
  </code></pre>
  
  <p>The function that I created does not work.  Do you know why?</p>