concept fct_rev() in category R
appears as: fct_rev()

This is an excerpt from Manning's book Exploring Data with R.
Having the bars arranged in this way really helps. We can tell, in an instant, that Ingolstadt has a greater population than Würzburg. What if you wanted the bars in the reverse order? In that case, the fct_rev() function is what’s needed. Let’s use the function, inspect the factor levels with levels() (Listing 9.28), and re-plot as before (Figure 9.3).
Listing 9.28. Reversing the order of factor levels in the name variable with the fct_rev() function
```{r fct_rev} german_cities_bayern$name <- fct_rev(german_cities_bayern$name) levels(german_cities_bayern$name) ``` #> [1] "Munich" "Nürnberg" "Augsburg" "Regensburg" "Ingolstadt" "Würzburg" #> [7] "Fürth" "Erlangen"Figure 9.3. The reversed order of bars in this plot was accomplished by reversing the factor levels of the name variable with fct_rev().
![]()