Primary exercises
- Facets (grid): variable for rows and/or variable for
columns.
 Try each of the followingfacet_gridlines and understand
the effects:
p <- ggplot( pulse ) +
  aes( x = weight, y = height, color = exercise, shape = gender ) +
  geom_point( size = 3, alpha = 0.8 )
p + facet_grid( . ~ exercise )
p + facet_grid( exercise ~ . )
p + facet_grid( gender ~ exercise )
p + facet_grid( exercise ~ gender )
p + facet_grid( exercise ~ gender, scales = "free" )
- Facets (wrap): multi-level variable in multiple rows and
columns.
 Now comparefacet_wrapwithfacet_grid:
p <- ggplot( pulse ) +
  aes( x = weight, y = height, color = exercise, shape = gender ) +
  geom_point( size = 3, alpha = 0.8 )
p + facet_grid( . ~ year )
p + facet_grid( year ~ . )
p + facet_wrap( ~ year )
p + facet_wrap( ~ year, scales = "free" )
- Visualize effect of running on pulse.
 Reconstruct the following image based on thepulsedata.
 Add componentcoord_fixed()to enforce that unit sizes are
identical for both axes.
 Usegeom_abline( slope = 1 )to get the line showing wherepulse1andpulse2are equal.
 Disable the warning message.

 
Copyright © 2023 Biomedical Data Sciences (BDS) | LUMC