title: colnames of a dataframe in r
body: <p>This might sound trivial, but I am facing an issue in finding column name of a dataframe(with 1 column)</p>
  
  <pre><code>&gt; a &lt;- data.frame(x = c(1,2,3,4,5), y = c("a", "a","c","d","r"))
  &gt; a
    x y
  1 1 a
  2 2 a
  3 3 c
  4 4 d
  5 5 r
  &gt; colnames(a)
  [1] "x" "y"
  &gt; names(a)
  [1] "x" "y"
  &gt; a1 &lt;- a[,1]
  &gt; class(a1)
  [1] "numeric"
  &gt; a1
  [1] 1 2 3 4 5
  &gt; a1 &lt;- as.data.frame(a[,1])
  &gt; a1
    a[, 1]
  1      1
  2      2
  3      3
  4      4
  5      5
  &gt; colnames(a1)
  [1] "a[, 1]"
  &gt; names(a1)
  [1] "a[, 1]"
  &gt; 
  </code></pre>
  
  <p>I am selecting 1 column from the dataframe "a", I want the output to be "x" when I query for the column name of a1. Appreciate help on this. Thanks</p>