[R] Representing 'Date' as 'Year - Quarter'

Vishal Belsare vishal.belsare at gmail.com
Sat May 31 10:39:02 CEST 2008


I have financial data on a a set of firms, with a quarterly period
(fundamental data). The data spans 10 years, and four quarters per
year. The present file (.csv) reads the Date columns as "200706" for
the second quarter of 2007; "199809" for the third quarter of 1997.

Is there a way I can convert it to something like "2007 Q2", "1998 Q3"?

I am aware of the yearqtr feature of the zoo package and ts also has
some facility to represent frequency.

However, the problem is that, my data isn't exactly a time series
right now. In each quarterly file, the date column has the same value
f.e 200706, however each row contains fundamental data of a different
firm.

Ultimately, I intend to aggregate the 40 or so files into one data frame.

So is it possible to read off the 199806 as a 'date' variable, with a
quarterly frequency? The reason why I am keen on this is that I can
then shape my further sub-setting in a form like which(... date ==
"1998 Q2") or so instead of forcing myself to write "1998/06/30" which
would indicate end of second quarter (I just think that is redundant).

Thanks in anticipation.


Best Regards

Vishal Belsare



More information about the R-help mailing list