A vector of factor:

```
vec <- factor(c('a','b','b','c','b','c'))
[1] a b b c b c                                                                                                                                                              
Levels: a b c

```

Would expect a new vector of

```
vec_new
[1] 3 1 1 2 1 2

```

The one with higher frequency will be converted to smaller integer.
Any help is appreciated, thank you