[R-SIG-Finance] Simple and fast date format conversion

Zanella Marco marco.zanella at inbox.com
Mon Aug 10 20:03:35 CEST 2009


Gentleman,
I have to convert a date to this format: nov 2009

A) I've loaded a daily dataset of returns like this:
> ret[1,]
        Date Ret
1 20090729  3.08

B) Naturally, I've transformed Date with as.Date() and now I have:
> ret[1,]
        Date Ret
1 2009-07-29 3.08

Ok, now I want to analyse data also accorpated for months, and weeks, not only daily.
I think the ways to do this can be various:
1) In A), where Date is simply a number, truncate the last two digits of Date (es. 200907). Then I can subset data for month thanks to new Date's format.
2) In B), after Date conversion to date format, proceed with a new format conversion (es. lug 2009)

But, how I can do this with R? I tried with truncate() and strptime() but failed.

Thanks.

Marco

____________________________________________________________
GET FREE 5GB EMAIL - Check out spam free email with many cool features!
Visit http://www.inbox.com/email to find out more!



More information about the R-SIG-Finance mailing list