I'm having a big trouble on dealing with levels names of a data frame.
I have a big data frame in which one of the colums is a factor with a LOT of levels.
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.
Let me give you a little example:
Say we have this simple data frame with one colum:
 bar1 bar2 bar3 bar2 bar4 bar5 bar3
Levels: bar1 bar2 bar3 bar4 bar5
If you want all the entries to be unique then a factor does not gain you much over just using a character variable.
Probably the simplest way to do what you want is to coerce to a character vector, use the
duplicated function to find the duplicates and paste something onto the end of them, then if you want use
factor to recoerce it back to a factor. Possibly something like:
df$col_foo <- factor( ifelse( duplicated(df$col_fo), paste(df$col_foo, '_x', sep=''), as.character(df$col_foo)))