A basic indexing query in R

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.

You can use forcats::fct_lump() for this task

If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

Thanks !! That looks like will simplify my job. Will try it !!