LoslegenKostenlos loslegen

Creating an initial plot

In the previous lessons, we tidied and cleaned our data to prepare it for visualization. Now we're ready to start recreating FiveThirtyEight's graph. Let's start with an initial plot. The dataset you created in the last chapter, rude_behaviors, is loaded.

Diese Übung ist Teil des Kurses

Categorical Data in the Tidyverse

Kurs anzeigen

Anleitung zur Übung

  • Order response_var by perc_rude
  • Make a bar plot of response_var by perc_rude. Save it as initial_plot.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

initial_plot <- rude_behaviors %>%
	# Reorder response_var by perc_rude
	mutate(response_var = ___(response_var, perc_rude)) %>%
	# Make a bar plot of perc_rude by response_var
	ggplot(aes(x = ___, y = ___)) + 
    geom_bar(stat = "identity")

# View your plot
initial_plot
Code bearbeiten und ausführen