1. Learn
  2. /
  3. Courses
  4. /
  5. Working with Dates and Times in R

Connected

Exercise

Generating sequences of datetimes

By combining addition and multiplication with sequences you can generate sequences of datetimes. For example, you can generate a sequence of periods from 1 day up to 10 days with,

1:10 * days(1)

Then by adding this sequence to a specific datetime, you can construct a sequence of datetimes from 1 day up to 10 days into the future

today() + 1:10 * days(1)

You had a meeting this morning at 8am and you'd like to have that meeting at the same time and day every two weeks for a year. Generate the meeting times in this exercise.

Instructions

100 XP
  • Create today_8am() by adding a period of 8 hours to today()
  • Create a sequence of periods from one period of two weeks, up to 26 periods of two weeks.
  • Add every_two_weeks to today_8am.