Only this week, get the SQL Complete Track of 9 courses in a special prize of $330 $89!
Factors and how to create them
Working with factors
14. Even more on factors and bar plots
Modifying factor variables


That took care of plotting information in ascending order. What if we wanted to plot it in reverse – in descending order?


We'd need another function, fct_rev(), which we'd apply to the result from fct_infreq(). Here's what we'd code:

ggplot(survey, aes(fct_rev(fct_infreq(age)))) + 
    geom_bar() + coord_flip()


Do the reverse of the last exercise – plot the marital status column in descending order. Remember to use ggplot(), geom_bar(), coord_flip(), and fct_infreq().

Stuck? Here's a hint!


ggplot(survey, aes(fct_rev(fct_infreq(mrt_status)))) + 
  geom_bar() + coord_flip()