从月末到时间顺序重塑日期
问题描述:
我有一些数据,如
Date col A col B col C .......
01/31/2008 00:00:00.000
01/31/2009 00:00:00.000
01/31/2010 00:00:00.000 bunch of data
01/31/2011 00:00:00.000
01/31/2012 00:00:00.000
01/31/2013 00:00:00.000
02/28/2008 00:00:00.000
02/28/2009 00:00:00.000 in these columns
02/28/2010 00:00:00.000
02/28/2011 00:00:00.000
02/28/2012 00:00:00.000
02/28/2011 00:00:00.000
03/31/2008 00:00:00.000
03/31/2009 00:00:00.000
03/31/2010 00:00:00.000
03/31/2011 00:00:00.000
03/31/2012 00:00:00.000
03/31/2013 00:00:00.000
.
.
.
我需要重新排列,以使其看起来像
I need them rearranged so that it looks likes
Date col A col B col C .......
01/31/2008 00:00:00.000
02/28/2008 00:00:00.000
03/31/2008 00:00:00.000 corresponding data
04/30/2008 00:00:00.000
05/31/2008 00:00:00.000
.
.
.
即现在它的月底,我只需要他们按顺序任何想法如何做到这一点,你可以假设每个日期有6个,从jan到dec的12个日期。谢谢。
ie right now its month end, I just need them in sequential order any idea how to do this, you can assume there are 6 per date and 12 dates from jan to dec. Thanks.
答
这可能有助于:
df <- df[with(df,order(Date)),]