I'm working on a data-munging pipeline with a lot of date columns in the data. Many R functions (e.g., set operations, sapply
, etc.) do no preserve date class, converting the dates to integers.
The strategies I see to deal with this are:
- Making sure that each function in the data-munging pipeline accepts and returns dates formatted as dates. Disadvantage: figuring out all the places to stick
as.Date()
is often tedious. - Living with dates as integers in all the munging steps, converting them to dates only at the end. This has the disadvantage of making date manipulation (e.g., sequencing with
by = "month"
) in the intermediate munging steps impossible without first converting to date.
Any other options I'm missing? Is there a way to make R play nice with dates? To clarify, the data I'm dealing with is not just a time series: multiple columns contain dates. So, as far as I can tell, xts
is of limited usefulness.