Get startedGet started for free

Why lubridate?

1. Why lubridate?

As you've seen R has some built-in support for storing dates and datetimes, but for the rest of the course you'll learn about a package called lubridate.

2. lubridate

lubridate is designed to make working with dates and times as easy as possible in R. It's a tidyverse package, which means it obeys some key principles, including playing nicely with R's existing datetime objects and being designed for humans, not computers. It also means it will fit nicely in your data analysis pipelines that use other tidyverse tools. In particular, in this course you'll combine lubridate with dplyr and ggplot2 to answer questions about data that includes a datetime variable. One nice aspect is that you don't need to worry about whether your datetimes are stored in Date objects, POSIXct objects or even time series objects like zoo or xts, the lubridate functions will have consistent behaviour. You only need to learn one function for any kind of datetime object.

3. Parsing a wide range of formats

You'll start by seeing how easy lubridate makes it to parse a character string into a datetime object. Although R has some built in parsing functions, lubridate's functions are simpler to use, more forgiving of different formats, and even allow parsing of many formats in one vector.

4. Manipulating datetimes

Then, you'll learn about lubridate functions for extracting and manipulating components of a datetime. You'll be able to pull out the month, day of the week or day of the year from a datetime. Combined with dplyr and ggplot that will allow you to make plots like this joyplot of the maximum daily temperature by month in Auckland.

5. Time spans

lubridate also has special objects for handling time spans - the time that passes between two time points. You'll learn how to use time spans to generate sequences of datetimes and calculate the length of time intervals like the lengths of reigns of the kings and queens of England.

6. Other lubridate features

In the final chapter you'll learn about lubridate functions for dealing with timezones, fast parsing of datetimes and outputting datetimes.

7. Let's practice!

Ready to get started? I'll see you in the next chapter.

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.