title: R: losing column names when adding rows to an empty data frame
body: <p>I am just starting with R and encountered a strange behaviour: when inserting the first row in an empty data frame, the original column names get lost.</p>
  
  <p>example:</p>
  
  <pre><code>a&lt;-data.frame(one = numeric(0), two = numeric(0))
  a
  #[1] one two
  #&lt;0 rows&gt; (or 0-length row.names)
  names(a)
  #[1] "one" "two"
  a&lt;-rbind(a, c(5,6))
  a
  #  X5 X6
  #1  5  6
  names(a)
  #[1] "X5" "X6"
  </code></pre>
  
  <p>As you can see, the column names <strong>one</strong> and <strong>two</strong> were replaced by <strong>X5</strong> and <strong>X6</strong>.</p>
  
  <p>Could somebody please tell me why this happens and is there a right way to do this without losing column names?</p>
  
  <p>A shotgun solution would be to save the names in an auxiliary vector and then add them back when finished working on the data frame.</p>
  
  <p>Thanks</p>
  
  <p>Context:</p>
  
  <p>I created a function which gathers some data and adds them as a new row to a data frame received as a parameter.
  I create the data frame, iterate through my data sources, passing the data.frame to each function call to be filled up with its results.</p>