Exercise

Labeling facets

If your factor levels are not clear, your facet labels may be confusing. You can assign proper labels in your original data before plotting (see next exercise), or you can use the labeller argument in the facet layer.

The default value is

  • label_value: Default, displays only the value

Common alternatives are:

  • label_both: Displays both the value and the variable name
  • label_context: Displays only the values or both the values and variables depending on whether multiple factors are faceted

Instructions 1/4

undefined XP
  • 1
    • Add a facet_grid() layer and facet cols according to the cyl using vars(). There is no labeling.
  • 2
    • Apply label_both to the labeller argument and check the output.
  • 3
    • Apply label_context to the labeller argument and check the output.
  • 4
    • In addition to label_context, let's facet by one more variable: vs.