[R] Extracting data only for particular index values from a zoo structure

Santosh Srinivas santosh.srinivas at gmail.com
Fri Nov 5 16:21:30 CET 2010


Hello All,

I have a zoo structure as follows:
> dput(tMRet)
structure(c(0.00138742474397713, -0.0309023681475112, 0.0390276302410908, 
0.0832282874685357, -0.00315002033871414, -0.0158548785709138, 
-0.0410876001496389, -0.0503189291168807, 0.00229628598547049, 
0.112348434473647, 0.0760004696254608, 0.100820586425124,
0.0803767768546975, 
0.0967805566974766, 0.054288018745434, 0.106415042990242,
0.0848339767191362, 
-0.0293833917022324, -0.0355384394730908, 0.0398272106900921), .Dim = c(20L,

1L), .Dimnames = list(c("Sep 2002", "Oct 2002", "Nov 2002", "Dec 2002", 
"Jan 2003", "Feb 2003", "Mar 2003", "Apr 2003", "May 2003", "Jun 2003", 
"Jul 2003", "Aug 2003", "Sep 2003", "Oct 2003", "Nov 2003", "Dec 2003", 
"Jan 2004", "Feb 2004", "Mar 2004", "Apr 2004"), "Close"), index =
structure(c(2002.66666666667, 
2002.75, 2002.83333333333, 2002.91666666667, 2003, 2003.08333333333, 
2003.16666666667, 2003.25, 2003.33333333333, 2003.41666666667, 
2003.5, 2003.58333333333, 2003.66666666667, 2003.75, 2003.83333333333, 
2003.91666666667, 2004, 2004.08333333333, 2004.16666666667, 2004.25
), class = "yearmon"), class = "zoo")

I want to extract only the values for say "November" but may span multiple
years.
How can I use conditions on the zoo index?

For info, I did an aggregate over daily data to reach here.

Have a great weekend!

Thanks.
S



More information about the R-help mailing list