Hi, I first should say I am new to R. I have searched without success the R-archives to see if I could find an answer to what I am about to ask you. My dataset is like: x fine 1 A 2010-12-09 07:57:33 2 B 2010-12-09 08:05:00 3 C 2010-12-08 20:42:00 ... that is: 'data.frame': 3 obs. of 2 variables: $ x : Factor w/ 3 levels "A","B","C": 1 2 3 $ fine: POSIXct, format: "2010-12-09 07:57:33" "2010-12-09 08:05:00" "2010-12-08 20:42:00" What I am trying to do is to build another variable fine1 that should contain the lagged value for "fine", that is: x fine fine1 1 A 2010-12-09 07:57:33 NA 2 B 2010-12-09 08:05:00 2010-12-09 07:57:33 3 C 2010-12-08 20:42:00 2010-12-09 08:05:00 How can I do that? Thanks, Luca Luca Meyer www.lucameyer.com IBM SPSS Statistics release 19.0.0 R version 2.12.0 (2010-10-15) Mac OS X 10.6.5 (10H574) - kernel Darwin 10.5.0
how to use diff() with different variables?
2 messages · Luca Meyer, Seeliger.Curt at epamail.epa.gov
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20101209/64634e49/attachment.pl>