I have a data frame in which one of the column is a 'factor'. This factor is a long tail factor. So I want to find the count of each factor, and those with sparse occurence replace with a generic factor (sat 'OTHER'). How do i do this efficiently in R? I used count. But how to index into count and add it as a new column in R ?? Then i can perhaps add a condition on that and replace. Help is appreciated. I am new to R.