Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Factors and how to create them
Working with factors
14. Even more on factors and bar plots
Modifying factor variables
Summary

Instruction

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

fct_rev(survey$age)

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()

Exercise

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!

Type:

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