Session Ready
Exercise

Examining intervals. Reigns of kings and queens

You can create an interval by using the operator %--% with two datetimes. For example ymd("2001-01-01") %--% ymd("2001-12-31") creates an interval for the year of 2001.

Once you have an interval you can find out certain properties like its start, end and length with int_start(), int_end() and int_length() respectively.

Practice by exploring the reigns of kings and queens of Britain (and its historical dominions).

Instructions
100 XP

We've put the data monarchs in your workspace.

  • Print monarchs to take a look at the data
  • Create a new column called reign that is an interval between from and to.
  • Create another new column, length, that is the interval length of reign. The rest of the pipeline we've filled in for you, it arranges by decreasing length and selects the name, length and dominion columns.