Making better plots

Dati categoriali nel 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.

Dati categoriali nel 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.

Dati categoriali nel Tidyverse

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

Dati categoriali nel 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.

Dati categoriali nel 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.

Dati categoriali nel Tidyverse

Let's practice!

Dati categoriali nel Tidyverse

Preparing Video For Download...