r - Order dataframe chronologically based on dates which are formatted %d/%m/%Y -
i have data has formatted (%d/%m/%y). data out of chronological order because sorted first number day, not month.
i'm hoping can specify order
or reorder
want sorting happen differently. i'm not sure how this.
here date data ordered:
date 1/1/2009 1/1/2010 1/1/2011 5/4/2009 5/4/2011 10/2/2009 10/3/2011 15/9/2010 15/3/2009 31/12/2011 31/7/2009
thanks suggestions.
when order column date
convert date format.
df[order(as.date(df$date,format="%d/%m/%y")),,drop=false] date 1 1/1/2009 6 10/2/2009 9 15/3/2009 4 5/4/2009 11 31/7/2009 2 1/1/2010 8 15/9/2010 3 1/1/2011 7 10/3/2011 5 5/4/2011 10 31/12/2011
Comments
Post a Comment