On Wed, May 2, 2012 at 4:27 PM, S. Georgakarakos <strat...@aegean.gr> wrote:
> In a time series ts object, like the z1.ts below:
>
> z1 = array(1:235)
>
> z1.ts = ts(z1, frequency =12)
>
> I would like to select only a certain month, for instance the "February"
> data
>
> If I transform the data to a matrix, I have the problem that 235 is not
> a multiple of 12
>
> I do not like to cut or add data, or program a loop to pick out the
> correct data.
>
> I am wondering if exist an easier way to select month data in a ts object.
>

Use cycle:

tt <- ts(1:235, frequency =12)
ts(tt[cycle(tt) == 2])


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

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to