I have a vector of numeric excel dates i.e.
date <- c(42963,42994,42903,42933,42964)
The output am I expecting when using
If you want to convert dates from Excel, you can use as.Date() with a specific origin. According to the documentation, '1900-01-01' is used as day ` in Excel.
date <- c(42963,42994,42903,42933,42964)
This is the result of as.Date():
as.Date(date, origin = "1900-01-01")
[1] "2017-08-18" "2017-09-18" "2017-06-19" "2017-07-19" "2017-08-19"
You can then use zoo::as.yearmon()` to get the expected outcome:
zoo::as.yearmon(as.Date(date, origin = "1900-01-01"))
[1] "Aug 2017" "Sep 2017" "Jun 2017" "Jul 2017" "Aug 2017"