title: Why does appending a character vector to a data frame turn it into a factor vector?
body: <blockquote>
  <p><strong>Question:</strong> Why does appending a character vector to a data frame (using either <code>cbind</code> or <code>data.frame</code>) turn the character vector into a factor vector?</p>
  <p>Does anyone know of functions besides <code>cbind</code> or <code>data.frame</code> which will allow me to avoid this unexpected and undesired behavior?</p>
  </blockquote>
  <p>Here's a MWE:</p>
  <pre><code>ab = data.frame(a= c(&quot;a&quot;, &quot;a&quot;), b= c(&quot;b&quot;, &quot;b&quot;))  
  c = c(&quot;c&quot;, &quot;c&quot;)  
  class(c)
  </code></pre>
  <blockquote>
  <p>'character'</p>
  </blockquote>
  <pre><code>abc1 = data.frame(ab, c)  
  class(abc1$c)
  </code></pre>
  <blockquote>
  <p>'factor'</p>
  </blockquote>
  <pre><code>class(abc1$a)
  </code></pre>
  <blockquote>
  <p>'character'</p>
  </blockquote>
  <pre><code>class(abc1$b)
  </code></pre>
  <blockquote>
  <p>'character'</p>
  </blockquote>
  <pre><code>abc2 = cbind(ab, c)  
  class(abc2$c)
  </code></pre>
  <blockquote>
  <p>'factor'</p>
  </blockquote>
  <pre><code>class(abc2$a)
  </code></pre>
  <blockquote>
  <p>'character'</p>
  </blockquote>
  <pre><code>class(abc2$b)
  </code></pre>
  <blockquote>
  <p>'character'</p>
  </blockquote>
  <p>This behavior would make a little more sense to me if the columns of the original data frame had been factors, or were being converted to factors too during the process of appending the third column, but at least with my version of R that does not seem to be the case.</p>