Aan de slagGa gratis aan de slag

Marginal bar chart

If you are interested in the distribution of alignment of all superheroes, it makes sense to construct a bar chart for just that single variable.

You can improve the interpretability of the plot, though, by implementing some sensible ordering. Superheroes that are "Neutral" show an alignment between "Good" and "Bad", so it makes sense to put that bar in the middle.

Deze oefening maakt deel uit van de cursus

Exploratory Data Analysis in R

Cursus bekijken

Oefeninstructies

  • Reorder the levels of align using the factor() function so that printing them reads "Bad", "Neutral", then "Good".
  • Create a bar chart of counts of the align variable.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Change the order of the levels in align
comics$align <- factor(___, 
                       levels = c(___, ___, ___))

# Create plot of align
ggplot(___, aes(x = ___)) + 
  geom_bar()
Code bewerken en uitvoeren