R Community of Practice
Week 2
Learning Goals
- understand the challenges of working with dates in R
- become familiar with the capabilities of the
lubridate
package
- use
lubridate
to filter and summarize data by date
Challenges of Working with Dates
- interpreted as strings when imported to R
- many date formats
- inconsistent time units (e.g. months, leap years, time zones)
The Data
Scenario: we have a spreadsheet of data tracking research consults from 2018 to 2023. We want to accomplish the following tasks:
- Change the date variable to date data type
- Summarize the number of consults by year
- Summarize consults by month for FY2022
Lubridate Time Spans
- durations - measure physical time in seconds
- periods – take into account human variations in time due to varying lengths of months, leap years, etc.
- intervals – time span defined with a start and end time

R Community of Practice Week 2