[R] Formating a zoo dataset .

From: Megh Dal <megh700004_at_yahoo.com>
Date: Sun, 02 Mar 2008 23:13:06 -0800 (PST)


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_at_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. Received on Mon 03 Mar 2008 - 07:17:19 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 03 Mar 2008 - 14:30:18 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive