Luca wrote on 12/09/2010 09:38:07 AM:
> ...
> 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? 

A few ways.  If you search for lag in the last couple of weeks, you'll see 
a discussion on this.  One is as follows:

 foo <- data.frame(x=LETTERS, fine=as.Date(0:25, origin='2010-01-01'))
 foo$fine1<-as.Date(NA)
 foo[2:nrow(foo),]$fine1 <- foo[1:(nrow(foo)-1),]$fine

cur
-- 
Curt Seeliger, Data Ranger
Raytheon Information Services - Contractor to ORD
seeliger.c...@epa.gov
541/754-4638



        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to