1. Rounding datetimes
You've seen how extracting components makes it easy to group and summarise based on the dates and times of observations. Rounding date times plays a similar role but is a little different.
2. Rounding versus extracting
Rounding a date will always result in another date object of the same type. Take a look at the first few release dates in the releases data. Extracting the hour component with hour gives the hour but we lose the other larger units: the year, month and day. In contrast if we use floor_date, a function which rounds down, with the unit argument set to hour, we remove the variation in minutes and seconds but retain the date the observation occurred on.
3. Rounding in lubridate
In lubridate there are three functions that round datetimes: round_date rounds to the closest unit, ceiling_date rounds up, and floor_date which you've already seen rounds down. All three take a unit argument, that specifies the unit to round to. You can also specify multiples of any of these units.
4. Let's practice!
Time for you to see rounding in action.