d <- "2021-05-21"
lubridate::month(d)
That gives 5 in output, I want May to be displayed there. Any guesses?
d <- "2021-05-21"
lubridate::month(d)
That gives 5 in output, I want May to be displayed there. Any guesses?
We could use lubridate package:
The trick here is to set the argument label of the function monthto TRUE:
library(lubridate)
ymd(d)
month(d, label=TRUE)
The given example isn't a date object, so you can extract the month from the string
month.name[as.numeric(strsplit(d,"-")[[1]][2])]
If it is a Date class
format(d,"%B")