Hello, I have a large data set with over thousands of entries and thousands of date. There are multiple columns. One of the column is called "date", and it has thousands of entries with the 2 different date type formats (i.e. %d%m%y
1/10/2018 and %m%d%y
10/2/2020). How can I change into a single date format?
#data.frame date column data with different data formats
Date
1 1/8/2018
2 10/5/2019
3 2/5/2019
4 24/6/2013
5 11/22/2020
6 11/10/2020
7 11/2/2020
8 3/12/2021
Update
using the parse_date_time
function from lubridate package
, some how I am able to convert the dates in to single format **Year-Month-Date**
. But there is some issue while converting into a single format.
How I parsed the date column and passes the mdy/dmy available date formats in date column
parse_date_time(data_df$Date, orders = c('mdy', 'dmy'))
Output
[1] "2018-01-08 UTC" "2019-10-05 UTC" "2019-02-05 UTC" "2013-06-24 UTC" "2020-11-22 UTC" "2020-11-10 UTC" "2020-11-02 UTC" "2021-03-12 UTC"
Note still, I am working on it. Current made the changes in temporary cloned data and cross checking the dates.