My Date column is of "Date" type and I want it that way. However, the Date variable shows January values for all years first, then Februray values for all the years, and so on. I would like to have it in the sequesnce of all months in the same year first, then all months in the next year. For example, 2015 -01-01, 2015-02-01, and so on all the way to 2015-12-01 and then similar details for 2016. Can you please help? I have shown a small data sample below. Thank you!
In the data.frame shown, the Date variable is a string, not a date. Best way to deal with this would be to use the {lubridate} package and the ymd() function to convert it before sorting with arrange()
Thanks @williaml!
Its strange that arrange works fine after the date is converted with as.Date. Earlier I was trying to use arrange before the Date was converted in its right data type and it wouldn't work.
Thanks @MyKo101! Yes, reprex somehow didn't take the already converted Date type. But thank you so much! Its all good now. I learnt today that arrange on date works better if applied after converting date into its date type. I was applying arrange before its conversion.