[R] converting a ts object to an xts object

Erin Hodgess erinm.hodgess at gmail.com
Sun Apr 11 22:43:09 CEST 2010

Dear R People:

This is probably is very simple question.  I have a monthly time
series, ibm$ts , that I would like to convert to a quarterly series.
I know that I could use "aggregate", but I am interested in the
to.quarterly conversion, please.

Here is my example:
> str(ibm$ts)
 Time-Series [1:144] from 1998 to 2010: 43.7 46.3 46 51.4 52.2 ...
> tsp(ibm$ts)
[1] 1998.000 2009.917   12.000
> to.quarterly(ibm$ts,indexAt='yearqtr')
Error in attr(x, "tsp") <- value :
  invalid time series parameters specified

Any suggestions would be much appreciated.


Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodgess at gmail.com

More information about the R-help mailing list