I am having a vector
monthData <- c("April", "June", "May", "August","July","September","December","November","October")
Is it possible to sort the vector in the chronological order of month name?
Thanks in advance
You could try sort on another vector consisting of full dates, in the same year, with the various month components:
dates <- as.Date(paste0("2020-", monthData, "-01"), format="%Y-%b-%d")
monthData[order(dates)]
[1] "April" "May" "June" "July" "August" "September"
[7] "October" "November" "December"
Data:
monthData <- c("April", "June", "May", "August", "July", "September", "December",
"November","October")