Session Ready
Exercise

Facets 2

In the previous exercise, you repeated the steps of filtering data and creating figures twice. In this exercise, you will use split() and lapply() to create multiple figures in less steps to avoid repetition.

Note that:

  • rbokeh is pre-loaded
  • plot_line() function is available to use in this session
plot_line <- function(x){
  figure() %>% 
    ly_lines(y =  count, year, data = x,
           color = age,  alpha = 1, width = 2)}
Instructions
100 XP
  • Split the tb dataframe by gender.
  • Create two a line plot for each gender group using plot_line() function and lapply().
  • Plot the two figures in a grid plot with a width of 1000, height of 600, and same axes limits.