Manipulating dates and times is usually quite hard and confusing. When time zones come in, it gets even harder; but still, sometime one needs to process date-time objects in their code. Lubridate
is one of a few great packages which makes things a bit easier.
Answers to the exercises are available here.
Please, do all exercises using the tidiverse
packages. If you obtained a different (correct) answer than those listed on the solutions page, please feel free to post your answer as a comment on that page.
Exercise 1
Parse ’01-31-2018′ as date.
Exercise 2
Check if the year of the date is a leap year.
Exercise 3
Check what day of the week (a full name) the date is.
Exercise 4
Set the day of the week to Friday. What date is it now?
Exercise 5
Parse ‘2018-01-01 1:0:0’ as a date-time with Chicago time.
- Work with different packages that help shape dates and times,
- learn about the lubridate package for quick and easy dates and times,
- and much more
Exercise 6
Print the time with London time.
Exercise 7
Create an interval starting at the date from exercise 1 and ending at the date from exercise 5.
Exercise 8
Check the duration of the interval.
Exercise 9
Check if the date ‘20180104’ is within the interval.
Exercise 10
Why is the result of exercise 9 FALSE
? How can you fix it?
Leave a Reply