0

How do I convert dates in this format in to dates in R:

month <- c("Dec 2013", "Mar 2014", "Jun 2014", "Sep 2014", "Dec 2014", "Mar 2015", "Jun 2015", "Sep 2015", "Dec 2015", "Mar 2016", "Jun 2016", "Sep 2016", "Dec 2016", "Mar 2017", "June 2017", "Sep 2017", "Dec 2017", "Mar 2018", "Jun 2018", "Sep 2018")

I had a look, but could only find answers for other types of date formats (e.g. Year-Month) but not for this.

william3031
  • 1,653
  • 1
  • 18
  • 39
  • 3
    You need a day component - `as.Date(paste0("01 ", month), format = "%d %b %Y")` – SymbolixAU Jan 03 '19 at 03:38
  • 2
    Related - https://stackoverflow.com/questions/42389170/date-formatting-mmm-yyyy or https://stackoverflow.com/questions/14324344/how-to-convert-a-mmmm-yyyy-string-to-a-date or https://stackoverflow.com/questions/26697399/convert-month-year-to-a-date-in-r or – thelatemail Jan 03 '19 at 04:29
  • I worked out that this works in `lubridate` without appending the day. `library(lubridate) month2 <- parse_date_time(month, orders = "OmY")` – william3031 Jan 03 '19 at 09:06

0 Answers0