title: R: Merging factor levels and creating sum in merged columns
body: <p>I am a beginner in R and this is driving me nuts.</p>
  
  <p>I have a dataframe:</p>
  
  <pre><code>someData = data.frame(Term=c('a', 'b', 'c', 'd', 'a', 'a', 'c', 'c'), Freq=c(1:8), Category=c(1,2,1,2,1,2,1,2));
  someData$Term = as.factor(someData$Term)
  someData$Category = as.factor(someData$Category)
  </code></pre>
  
  <p>and would like to combine terms a and c (both factors) into x while summing their respective frequencies and while maintaining the categories so that I have the following resulting dataframe:</p>
  
  <pre><code>Term Freq Category
  x    16       1
  b    2        2
  d    4        2
  x    14       2
  </code></pre>
  
  <p>The following code only changes all names to x, but does not sum its values. </p>
  
  <pre><code>combine &lt;- c("a", "c");
  levels(somedata$Term)[levels(somedata$Term) %in% combine] &lt;- paste("x");
  </code></pre>