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
Modifying factor variables
19. Collapsing levels to "Other", part 2
Summary

Instruction

We can also use fct_lump() to show the levels that occur least – we just include a minus (-) in the n argument, like so:

fct_lump(survey$primary_language, n = -5)

If we wanted to find how often the five least-common languages occur in the survey dataset, we'd code:

fct_lump(survey$primary_language, n = -5) %>%
  fct_count()

Notice the pipe operator and the fct_count() function!

Exercise

Use fct_lump(), fct_count(), and the pipe operator to find the five least-common employment situations. Use employment_status in survey.

Stuck? Here's a hint!

Type:

fct_lump(survey$employment_status, n = -5) %>% fct_count()