Reputation: 57
I have an xts objects which is yearqtr (1990 Q1 2012 Q3). I want to work with the data going up to 2011 Q3. I tried several things:
data["1990::2011:3"]
data["1990/2012-3"]
The 3 is treated like monthly, so if i use
data["1990::2012:9]
data["1990/2012-9]
I get the third quarter. However, this is inconvenient. I would like to have the third quarter, whenever i put a three in the brackats. How would I write this ?
Best regards and thanks in advance
Upvotes: 0
Views: 850
Reputation: 17189
You can use subset
subset(data, index(data) >= as.yearqtr('1995 Q1') & index(data) <= as.yearqtr('2011 Q1') )
or just normal subset using [ ]
data[index(data) >= as.yearqtr('2000 Q1') & index(data) <= as.yearqtr('2011 Q1') ]
Upvotes: 1
Reputation: 121568
Try this
data["1990::2011:x"]
Where x = 7 or 8 or 9 : they give all the same result.
Here an example
x <- as.yearqtr(1990 + seq(0, 4*(2013-1990))/4)
zz <- xts(rnorm(length(x)),x, frequency = 4)
as.ts(zz["1990::2011:9"])
Upvotes: 0