[R] simple ts() object question
Gabor Grothendieck
ggrothendieck at gmail.com
Sun Sep 5 06:20:50 CEST 2010
On Sun, Sep 5, 2010 at 12:08 AM, StatWM <wmusial at gmx.de> wrote:
>
> Dear Community,
>
> say, I have an annual ts() object sampled from 1960 to 1969 like:
>
> ta<-ts(1:10, start=1960, frequency=1)
>
> How can I extract the value from the year 1965?
>
> I mean, not by:
>
> ta[6]
>
> but by something like:
>
> ta[1965]
>
> where I'm directly referring to the year of the observation?
>
> Thank you in advance!
>
Use window.ts
> ta <- ts(1:10, start = 1960)
> window(ta, start = 1965, end = 1965)
Time Series:
Start = 1965
End = 1965
Frequency = 1
[1] 6
--
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