1

I have a monthly xts object, and the function frequency() returns a value of 1, however I would expect 12. The function cycle() also does not return month numbers, but instead a value of 1 for each observation.

library('quantmod')
getSymbols("GS10", src="FRED")
frequency(GS10)
cycle(GS10)
Joshua Ulrich
  • 173,410
  • 32
  • 338
  • 418
HRC
  • 107
  • 7
  • A daily object with one date in each month is not a monthly object. – G. Grothendieck Mar 16 '15 at 22:32
  • @G.Grothendieck - I'm not sure why you think it is a daily object. There is one observation per month, hence monthly object. As another example, one observation per year is an annual observation, not a daily observation. – HRC Mar 17 '15 at 13:03
  • `"Date"` class times are daily objects. It doesn't matter that there happens to be one date per month. – G. Grothendieck Mar 17 '15 at 14:31

1 Answers1

1

Try this:

time(GS10) <- as.yearmon(time(GS10))
G. Grothendieck
  • 254,981
  • 17
  • 203
  • 341