Get startedGet started for free

Why use dates?

1. Why use dates?

As you saw in the exercises it's just a little bit of extra work to get dates recognized as dates by R, but that extra work really pays off. Once an object is a date, you can plot and do math with it and get the results you'd expect.

2. Dates act like numbers

Behind the scenes Date objects are stored as the number of days since Jan 1st 1970. That means standard mathematical comparisons work as you'd expect. You can ask if one date is greater than another, which will be true if it occurs after the other. You can add days to a date. And you can find the difference between dates.

3. Plotting with dates

It also means plotting libraries can be built to plot dates. The base R plot function will happily accept dates,

4. Plotting with dates

as will ggplot2. You'll see in the exercises if you need to set axis properties, you'll need to do it with date objects. Of course all this will be more interesting when your dates are part of a larger data set.

5. R releases

Let's take a closer look at the data you imported in the previous exercises. releases is a data set that describes the release dates of all versions of R. The first version 0 (point) 60 was released on the 4th of December 1997. R version numbers take the form: major release number, dot, minor release number, dot, patch number. Those numbers are stored in the major, minor and patch columns. When a release is a patch only the patch number increases, if it's a minor release the minor number increases and the patch number resets to zero, if it's a major release the major number increases and both the minor and patch numbers reset to zero. You can see the type of release in the type column.

6. Let's practice!

In the exercises you'll plot the release dates to explore when releases have occurred and subtract dates to see how long it's been since the last release.