title: How to get the name of a variable isolated from a data.frame using indexing?
body: <p>Given a variable isolated from a data frame, how does one obtain it's name?
  It needs to work in functions where indexing is done internally (eg. apply).</p>
  
  <pre><code>df&lt;-data.frame(a=1:10,b=1:10)
  
  names(df[,1])
  </code></pre>
  
  <p>produces:</p>
  
  <pre><code>&gt;NULL
  
  test&lt;-df[,1]
  test[0]
  </code></pre>
  
  <p>Here is an example where this may be useful:</p>
  
  <pre><code>library(plyr)
  relabel&lt;-colwise(function(column){
    column&lt;-paste(names(column),column)})
  relabel(df)
  </code></pre>
  
  <p>gives</p>
  
  <pre><code>data.frame(a=c(.1,.2,.3,...), b=c(.1,.2,...))
  </code></pre>
  
  <p>The desired results would be:</p>
  
  <pre><code>data.frame(a=c('a.1','a.2','a.3'), b=c('b.1','b.2', 'b.2'))
  </code></pre>