Exercise

Setting order

If you want to change the order of your facets, it's best to properly define your factor variables before plotting.

Let's see this in action with the mtcars transmission variable am. In this case, 0 = "automatic" and 1 = "manual".

Here, we'll make am a factor variable and relabel the numbers to proper names. The default order is alphabetical. To rearrange them we'll call fct_rev() from the forcats package to reverse the order.

Instructions 1/2

undefined XP
  • 1
    • Explicitly label the 0 and 1 values of the am column as "automatic" and "manual", respectively.
  • 2
    • Define a specific order using separate levels and labels arguments. Recall that 1 is "manual" and 0 is "automatic".