How to convert 10-03-2021 into October-03-2021?
I have column in data frame in MM-DD-YYYY which needs to be converted into Month Name- Date- Year
example
10-03-2021
into October-03-2021
How to convert 10-03-2021 into October-03-2021?
I have column in data frame in MM-DD-YYYY which needs to be converted into Month Name- Date- Year
example
10-03-2021
into October-03-2021
You have two parts: parsing the date, and then printing it with your format.
Parsing is quite easy with the lubridate package:
> library(lubridate)
> dates <- mdy(c('10-03-2021', '01-31-1995'))
> dates
[1] "2021-10-03" "1995-01-31"
For printing, you can then use the format()
function:
> format(dates, '%B-%d-%Y')
[1] "October-03-2021" "January-31-1995"
%B
is the full name of the month, %d
the day and %Y
the year (with all 4 digits)