title: String as factor in R
body: <p>When creating a data frame in R, strings are by default converted to factors (which I don't mind). But when I want to create a new row to my data frame, I can't find a way to encode a string as a factor. If I use <code>factor()</code>, the string is converted to a numeral, but is still not a factor. Under either scenario, I can't append my new row to the data frame because the new row is not a factor. What I want is to have my new row behave just like my data frame, that is with a string converted to a factor.</p>
  
  <pre><code>&gt; data.frame(c("Name one", "Name two")) -&gt; my.data
  &gt; colnames(my.data) &lt;- "Names"
  &gt; is.factor(my.data$Names)
  [1] TRUE
  &gt; new.row1 &lt;- c("Name three")
  &gt; is.factor(new.row1)[1]
  [1] FALSE
  &gt; new.row2 &lt;- c(factor("Name three"))
  &gt; new.row2
  [1] 1
  &gt; is.factor(new.row2)[1]
  [1] FALSE
  &gt; rbind(my.data, new.row1)
       Names
  1 Name one
  2 Name two
  3     &lt;NA&gt;
  Warning message:
  In `[&lt;-.factor`(`*tmp*`, ri, value = "Name three") :
    invalid factor level, NA generated
  &gt; rbind(my.data, new.row2)
       Names
  1 Name one
  2 Name two
  3     &lt;NA&gt;
  Warning message:
  In `[&lt;-.factor`(`*tmp*`, ri, value = 1L) :
    invalid factor level, NA generated
  &gt; 
  </code></pre>