Parsing Dates and Time – Part 2: Exercises
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
In the exercises below, we will continue working with lubridate and examine more features of the library.
Answers to these exercises are available here.
Please check the previous exercise 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.
Exercise 1
Here is a string, which looks like:
dt <- "Apr, 11th 2018 17:00"
.
Convert it to R’s date-time format.
Exercise 2
Here is another representation of dt:
dt <- "2018/04/11 17:00"
.
Convert it to R’s date-time format.
Exercise 3
Suppose dt is in this format:
dt <- "11.4.2018 17"
Convert it to R’s date-time format.
Exercise 4
Lubridate allows you to parse dates and times in a convoluted format into R’s date-time format.
dt <- "Wed apr 11th 2018 at 7pm"
Parse it properly using the lubridate’s function.
Exercise 5
Suppose I have to parse the 110th day of 2018; how do I achieve that?
Exercise 6
Now, suppose you have two strings: “1 2018”, which represents the first quarter of 2018 and “3 2018”, which represents the 3rd quarter of 2018. Using lubridate’s functions, parse it properly.
Exercise 7
Suppose you have to parse the 10th week of 2018; please parse it with lubridate.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.