Making better plots

Categorische gegevens in de Tidyverse

Emily Robinson

Data Scientist

A scatterplot with "problem" on the y-axis and "percentage considering a problem" on the x-axis. Problems include Expectations, Dirty Data, and Domain Expertise. The plot is not ordered so the points are scattered around.

Categorische gegevens in de Tidyverse

Reordering factors

ggplot(WorkChallenges, aes(x = fct_reorder(question, perc_problem),
                           y = perc_problem)) +
  geom_point() + 
  coord_flip()              

The same scatterplot as before but now ordered so from left to right it goes from the least percentage considering a problem to the most.

Categorische gegevens in de Tidyverse

A bar graph with job title on the y-axis and count on the x-axis. The bar is not ordered by count.

Categorische gegevens in de Tidyverse

Reordering bar chart

ggplot(multiple_choice_responses, aes(x = fct_infreq(CurrentJobTitleSelect)) +
   geom_bar() +
   coord_flip()              

The same bar chart as before but now ordered from top to bottom in increasing count.

Categorische gegevens in de Tidyverse

Reversing factor levels

ggplot(multiple_choice_responses, aes(x = fct_rev(fct_infreq(CurrentJobTitleSelect)))) +
    geom_bar() + 
    coord_flip()

The same bar chart as before but now ordered from top to bottom in decreasing count.

Categorische gegevens in de Tidyverse

Let's practice!

Categorische gegevens in de Tidyverse

Preparing Video For Download...