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:
> >
>
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
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
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
4 matches
Mail list logo