[R] Time series indexes
Thomas Petzoldt
petzoldt at rcs.urz.tu-dresden.de
Wed Apr 27 08:21:04 CEST 2005
Fernando Saldanha schrieb:
> I tried to assign values to specific elements of a time series and got
> in trouble. The code below should be almost self-explanatory. I wanted
> to assign 0 to the first element of x, but instead I assigned zero to
> the second element of x, which is not what I wanted. Is there a
> function that will allow me to do this without going into index
> arithmetic (which would be prone to errors)?
>
> FS
>
>
>>x<- ts(c(1,2,3,4), start = 2)
>>x
>
> Time Series:
> Start = 2
> End = 5
> Frequency = 1
> [1] 1 2 3 4
>
>>x[2] <- 0
>>x
>
> Time Series:
> Start = 2
> End = 5
> Frequency = 1
> [1] 1 0 3 4
Hello Fernando,
is this what you want:
x[time(x)==2] <- 0
ThPe
More information about the R-help
mailing list