[R] Re: [S] subscripts error
Kenneth Cabrera
krcabrer at epm.net.co
Fri Aug 1 12:43:21 CEST 2003
Hi Gianluca:
try :
x2<-x[1:(length(x)-2)]-x[3:length(x)]
OR
x2<-diff(x,lag=2)
Hope it helps.
Gianluca wrote:
> Hi all,
>
> I'm back to use S-Plus after a lot programming with SAS, so it's hard
> for me to face many simple problems....
> Let's come to what is going to make me crazy. I have a simple 1000 obs
> time series, called "x".
> If I want to compute second order differences just typing:
> x2<-x[1:length(x)-2]-x[3:length(x)]
>
> but I get the following error message:
>
> Error in x[1:length(x) - 2]: Only 0's may be mixed with negative
> subscripts
> Much more interesting is that with first order differences it works
> perfectly....
> Thanks in advance to all.
>
> Gianluca
--
Kenneth Roy Cabrera Torres
Celular +57 (315) 405 9339
More information about the R-help
mailing list