title: rbind not giving expected output in r
body: <p>I created an empty data frame with column names and was trying to insert rows containing a string and a number. This is my code, however I do not get the expected output.</p>
  
  <pre><code>df &lt;- data.frame(col1=character(), col2=numeric(), stringsAsFactors=FALSE)
  for(i in 1:10)
  {
      entry = c("hello",i)
      df = rbind(df,entry)
  }
  </code></pre>
  
  <p>EDIT : The rbind line initially looked like this , testdf = rbind(df,entry). Thanks Pascal for pointing out, editing this since it was a typo.</p>
  
  <p>EDIT-TWO : I tried doing based on Gregor's suggestion to create the columns first and them bind them together. But how do I ensure that the column names remain as firstcol and secondcol,and don't change to col1 and col2?</p>
  
  <pre><code>df &lt;- data.frame(col1=character(), col2=numeric(), stringsAsFactors=FALSE)
  firstcol = NULL
  secondcol = NULL
  
  for(i in 1:10)
  {
      col1 = c(col1,"hello")
      col2 = c(col2,i)
  }
  </code></pre>