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

Gabor Grothendieck ggrothendieck at gmail.com
Fri Nov 5 17:07:47 CET 2010


On Fri, Nov 5, 2010 at 11:54 AM, Santosh Srinivas
<santosh.srinivas at gmail.com> wrote:
> Thanks Gabor for pointing in the right direction.
> Looked up cycle and the doc is tough to understand " cycle gives the
> positions in the cycle of each observation." ... how is cycle defined.
>
> I just extended your idea to make it readable for an avg. user in the
> following way
> mRet[format(index(mRet),"%m")==11]
>

cycle is defined in the core of R and is extended for additional
methods by zoo.  For a zoo object applying cycle to zoo applies it to
the zoo object's index.   If the index is a yearmon object, ym, then
cycle(ym) gives the month number at each time, 1 for Jan, 2 for Feb,
etc.  If the index is a yearqtr object, yq, then cycle(yq) gives the
quarter number at each time, 1 for Q1, 2 for Q2, etc.

For a zooreg object cycle will give the position in the cycle at each
time.  If the zooreg object has frequency F then the cycle values will
be 1, 2, ..., F.

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-help mailing list