ComenzarEmpieza gratis

Adding visual anchors

A nice property of the log fold change is it is symmetric: a value of 1 means two times 'bigger', and -1 means two times 'smaller.' Due to this, the position of 0 on the x-axis marks the switch point between count declines and increases over years. When your data has a natural break-point like this, it is good if the chart shows it as a focal-point as well.

The code provided will make a basic point chart of the log fold change for the dates. To improve it, we will do two things. First, reorder the dots in descending order like in the previous exercise. Second, add a guideline at x = 0 to show the neutral point by adding geom_vline() (for verticalline) to your plot object with the argument xintercept set to 0.

Este ejercicio forma parte del curso

Visualization Best Practices in R

Ver curso

Instrucciones del ejercicio

  • Order dots in descending by wrapping the y mapping in reorder().
  • Add visual anchor at x = 0 with geom_vline().

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

who_subset %>% 
	# calculate the log fold change between 2002 and 1992
	mutate(logFoldChange = log2(cases_2002/cases_1992)) %>% 
	# set y axis as country ordered with respect to logFoldChange
	ggplot(aes(x = logFoldChange, y = ___)) +
	geom_point() +
	# add a visual anchor at x = 0
	___
Editar y ejecutar código