1

I am having the data set filtered from from other data base, which is as below

        Date| freq
____________|_________
 01-Aug-2017| 3079
 02-Aug-2017| 3239
 03-Aug-2017| 3026
 04-Aug-2017| 2700
 05-Aug-2017|  846
 05-Jul-2017| 2647
 06-Aug-2017|  579
 07-Aug-2017| 3145
 08-Aug-2017| 3386
 09-Aug-2017| 3350
 10-Aug-2017| 3127
 11-Aug-2017| 2824
 12-Aug-2017|  784
 12-Jun-2017| 2359
 13-Aug-2017| 575
 13-Jun-2017| 2074
 14-Aug-2017| 3258
 14-Jun-2017| 2022
 15-Aug-2017| 2948
 15-Jun-2017| 2143

Sorting is not happening as per the date, but as per the characters. I tried to convert the date format with as.Date but not successful. It will be a great help, to convert the date in any format and sort it date wise. Any support in this direction will be a great help.

Thanks, Praveen

Hardik Gupta
  • 4,700
  • 9
  • 41
  • 83

1 Answers1

1

Let assume your dataframe is named 'd' Apply code to sort according to dates:

d[order(as.Date(d$V3, format="%d/%m/%Y)),]
PraneetNigam
  • 959
  • 9
  • 16
  • In this case, we need to use `format = "%d-%b-%Y"` instead of `format = "%d/%m/%Y"`. [This](http://www.statmethods.net/input/dates.html) can help to understand the specification of dates format. – nghauran Oct 11 '17 at 10:08
  • Yes in the above case we can use "%d-%b-%Y" format. – PraneetNigam Oct 11 '17 at 10:53