Answers to these exercises are available here.
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.
Lubridate offers two functions to see the date and date-time, at the moment, in the system. Use them to see the time in your time zone.
There is a base function named “difftime” to find time difference between two times. Now use this to find out the time difference in weeks between.
x <- "11 th april 2012"
y <- "April 24th 2018 11:59:59"
Do the same as above and find the difference between the system time and x, in hours.
Lets say we have:
x <- "11 th april 2018 11.30.00"
We want to add one day to x. How do we achieve that?
Now add 100 hours to x and find which date-time it is.
Now, how can we get the date-time of 3 weeks prior to x?
Now, read about the duration and spans from lubridate’s vignette. Try getting the date-time 10 years prior to x first by subtracting with years and then by using 10 year duration’s. See if they are similar and try to reason it.
- Become a Top R Programmer Fast with our Individual Coaching Program
- Explore all our (>4000) R exercises
- Find an R course using our R Course Finder directory
- Subscribe to receive weekly updates and bonus sets by email
- Share with your friends and colleagues using the buttons below