Suppose I have following dataset :
  > head(data1)
      Date      Return
1 03/31/00  0.14230650
2 04/28/00 -0.03276228
3 05/31/00 -0.06527890
4 06/30/00 -0.04999873
5 07/31/00 -0.01447902
6 08/31/00  0.22265729

  Now I convert it to zoo object :
   
  > data11 = zoo(data1[,2], as.Date(data1[,1], format="%m/%d/%y"))
  > head(data11)
 2000-03-31  2000-04-28  2000-05-31  2000-06-30  2000-07-31  2000-08-31 
 0.14230650 -0.03276228 -0.06527890 -0.04999873 -0.01447902  0.22265729 
   
  Clearly those are monthly data. Therefore I want to convert it to mm-yy 
format. I used following code :
  data111 = zoo(coredata(data11), format(index(data11), "%m/%y"))
   
  However what I got is that :
  > head(data111)
       01/01        01/02        01/03        01/04        01/05        01/06 
-0.001388889 -0.016274826 -0.047707664  0.001104362 -0.077961541  0.017637141 
> tail(data111)
       12/02        12/03        12/04        12/05        12/06        12/07 
 0.058660676 -0.018067833 -0.055569851  0.007142888  0.051162052  0.052643733 

  It is evident that month order has been changed. Can anyone here tell me how 
to get correct order like :
   
  01/01, 02/01, 03/01..................
   
  Your help is highly appreciated
   
  Regards,

       
---------------------------------

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to