Re: [R] how to extract data by specific months from a monthly ts object

2008-01-20 Thread tom soyer
Thanks Marc and Gabor, I got it! On 1/20/08, Marc Schwartz <[EMAIL PROTECTED]> wrote: > > tom soyer wrote: > > Hi, > > > > I am trying to extract data from a ts object by month, e.g., extract > Jan, > > Feb, and Aug data from a monthly ts object. I tried the following but it > > didn't work: > > >

Re: [R] how to extract data by specific months from a monthly ts object

2008-01-20 Thread Gabor Grothendieck
Try %in% ta[ cycle(ta) %in% c(1, 2, 8) ] cycle(ta) == c(1, 2) works only in this case since c(1, 2) is recycled to cycle(ta) == rep(c(1, 2), length = length(ta)) It would not have worked had your data had started on an even numbered month. This also works: cyc <- cycle(ta) ta[ cyc == 1 | cy

Re: [R] how to extract data by specific months from a monthly ts object

2008-01-20 Thread Marc Schwartz
tom soyer wrote: > Hi, > > I am trying to extract data from a ts object by month, e.g., extract Jan, > Feb, and Aug data from a monthly ts object. I tried the following but it > didn't work: > >> xa=1:50 >> ta=ts(xa,start=c(1990,1),frequency=12) >> ta[cycle(ta)==c(1,2)] # this method works but it

[R] how to extract data by specific months from a monthly ts object

2008-01-20 Thread tom soyer
Hi, I am trying to extract data from a ts object by month, e.g., extract Jan, Feb, and Aug data from a monthly ts object. I tried the following but it didn't work: > xa=1:50 > ta=ts(xa,start=c(1990,1),frequency=12) > ta[cycle(ta)==c(1,2)] # this method works but it's not what I want [1] 1 2 13