[R] Odd results with lag

From: Worik R <worikr_at_gmail.com>
Date: Fri, 08 Apr 2011 10:11:36 +1200


Given a vector:

> S <- c(1,1,0,0,1,1,-1,-1,-1,0,1)

Then I expected lag(S) to give...

c(1,0,0,1,1,-1,-1,-1,0,1)

but instead...

> S

 [1] 1 1 0 0 1 1 -1 -1 -1 0 1
> lag(S)

 [1] 1 1 0 0 1 1 -1 -1 -1 0 1
attr(,"tsp")
[1] 0 10 1
>

This is very odd. What is happening?

I get what I using S[-1] so I have no problem, but I obviously do not understand some thing!

Worik

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 07 Apr 2011 - 22:13:30 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 07 Apr 2011 - 23:50:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive