I'm working with Lubridate package for formatting the dates in my data.
str(base$date)
#> chr [1:38] " 23.09.2020 " " 23.09.2020 " " 17.06.2020 " " 03.06.2020 " ...
base$date <-dmy(base$date)
str(base$date)
#> Date[1:38], format: "2020-09-23" "2020-09-23" "2020-06-17" "2020-06-03" "2020-05-27" ...
Since my original data for the dates are in format character, I wanted to convert it in to format date (dd/mm/yyyy) with function dmy of Lubridate package. And I'm getting format date in yyyy/mm/dd. Is't the function dmy supposed to give me the date in dd/mm/yyyy since d stands for day, m stands for month and y for year ?
CodePudding user response:
lubridate::dmy()
creates a date-object from a string in the DMY format.
When you print a date object, it is by default shown in the ISO 8601 format aka YYYY-MM-DD.
To print the date in the DMY format, you can use format(date, "%d/%m/%y")
(note that this will convert the date object to a string).
To change the default way dates are printed, you have to look at locales (eg see this).