concept fct_lump_n() in category R

This is an excerpt from Manning's book Exploring Data with R.
Let’s get back to our bar plot (which now looks great by the way, thanks to forcats). We might imagine a situation where the total number of categories is exceedingly large and so we’d want to show just a few categories while lumping the rest into an ‘others’ category. Amazingly there is a set of forcats functions for that, and the function names all begin with fct_lump_. All of these variations perform lumping by different criteria; we’ll choose to use the fct_lump_n() function for our next example. It lumps all levels except for the n most frequent of them. The example shown in Listing 9.33 synthesizes a number of fct_*() functions together to modify the levels of the state factor column in a mutate() statement. First, we do as before and obtain factor levels by frequency. Then, we use fct_lump_n() to get the five top states in terms of city count, lumping the rest into the "Other" level. Finally, we reverse the entire order of levels with fct_rev() so that the bars in the plot appear from largest to smallest (from top to bottom), with the "Other" level at the very bottom. Figure 9.7 shows the plot that results from the code shown in Listing 9.33.
Listing 9.33. Further refinement of the city count bar plot by incorporating the fct_lump_n() function (just before reversing levels)
```{r fct_lump_n} german_cities %>% mutate(state = state %>% fct_infreq() %>% fct_lump_n(5) %>% fct_rev()) %>% ggplot(aes(y = state)) + geom_bar() ```