0

I have various data sources and each data source has a different convention on naming dates.

Example:

Some are: May 16,2017 as Character type

While others are: 16/05/2017 as Date type

Is it possible to write a code that would coerce everything including those in character to dd/mm/yyyy date format?

lb0389
  • 127
  • 1
  • 9

1 Answers1

0

We could use the parse_date_time from lubridate which takes multiple formats

library(lubridate)
parse_date_time(str1, c("mdy", "dmy"))
#[1] "2017-05-16 UTC" "2017-05-16 UTC"

data

str1 <- c("May 16,2017", "16/05/2017")
akrun
  • 874,273
  • 37
  • 540
  • 662