[R] select month data in ts objects
Gabor Grothendieck
ggrothendieck at gmail.com
Thu May 3 12:41:25 CEST 2012
On Wed, May 2, 2012 at 4:27 PM, S. Georgakarakos <stratisg at 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
More information about the R-help
mailing list