title: Add a new level to a factor and substitute existing one
body: <p>I'm having a big trouble on dealing with levels names of a data frame.</p>
  
  <p>I have a big data frame in which one of the colums is a factor with a LOT of levels.</p>
  
  <p>The problem is that some of this data are duplicated and the next step in my analysis do not accept duplicated data. So I need to change the name of the duplicated level so I can move on to my next step.</p>
  
  <p>Let me give you a little example:</p>
  
  <p>Say we have this simple data frame with one colum:</p>
  
  <pre><code>&gt; df
  col_foo
  1   bar1
  2   bar2
  3   bar3
  4   bar2
  5   bar4
  6   bar5
  7   bar3
  </code></pre>
  
  <p>If we look at the column, we see that it is a factor with 5 distinct levels.</p>
  
  <pre><code>&gt;df$col_foo
  [1] bar1 bar2 bar3 bar2 bar4 bar5 bar3
  Levels: bar1 bar2 bar3 bar4 bar5
  </code></pre>
  
  <p>Ok, the problem comes now. See that levels <code>bar2</code> and <code>bar3</code> are <strong>duplicated</strong>. What I want to know is how can I add a level name, something like <code>bar2_X</code> and substitute only the duplicated one for this. So the dataframe should become this:</p>
  
  <pre><code>&gt; df
  col_foo
  1   bar1
  2   bar2
  3   bar3
  4   bar2_X
  5   bar4
  6   bar5
  7   bar3_X
  </code></pre>
  
  <p>Is that possible ? I cannot change the class of the column, it should still be a factor, so solutions that need to change it will not solve my problem unless it is possible to coerce to factor again.</p>
  
  <p>Thanks</p>