Re: [R] lag a data.frame column?

2009-09-10 Thread Angel Spassov
Mark Knecht wrote (09.Sep.2009 at 10:43 -0700): Sometimes it's the simple things... Why doesn't this lag X$x by 3 and place it in X$x1? (i.e. - Na's in the first 3 rows and then values showing up...) The help page does talk about time series. If lag doesn't work on data.frame columns then

[R] lag a data.frame column?

2009-09-09 Thread Mark Knecht
Sometimes it's the simple things... Why doesn't this lag X$x by 3 and place it in X$x1? (i.e. - Na's in the first 3 rows and then values showing up...) The help page does talk about time series. If lag doesn't work on data.frame columns then what would be the right function to use to lag by a

Re: [R] lag a data.frame column?

2009-09-09 Thread Achim Zeileis
On Wed, 9 Sep 2009, Mark Knecht wrote: Sometimes it's the simple things... Why doesn't this lag X$x by 3 and place it in X$x1? It does. (i.e. - Na's in the first 3 rows and then values showing up...) Because this is not how the ts class handles lags. What happens is that X$x is

Re: [R] lag a data.frame column?

2009-09-09 Thread Gabor Grothendieck
Try this: x - 1:10 head(c(rep(NA, 3), x), -3) [1] NA NA NA 1 2 3 4 5 6 7 tail(c(x, rep(NA, 3)), -3) [1] 4 5 6 7 8 9 10 NA NA NA depending on which direction you want. On Wed, Sep 9, 2009 at 1:43 PM, Mark Knecht markkne...@gmail.com wrote: Sometimes it's the simple things...

Re: [R] lag a data.frame column?

2009-09-09 Thread Mark Knecht
On Wed, Sep 9, 2009 at 11:09 AM, Achim Zeileis achim.zeil...@wu-wien.ac.at wrote: On Wed, 9 Sep 2009, Mark Knecht wrote: Sometimes it's the simple things... Why doesn't this lag X$x by 3 and place it in X$x1? It does. (i.e. - Na's in the first 3 rows and then values showing up...)