[R] difference in dates

Erin Hodgess erinm.hodgess at gmail.com
Mon Jun 21 02:13:24 CEST 2010


Dear R People:

I have a data frame with the two following date columns:


> a.df[1:10,c(1,6)]
           DATE      DEATH
1207 2009-04-16 2009-05-06
1514 2009-04-16 2009-05-06
2548 2009-04-16 2009-05-08
3430 2009-04-16 2009-05-09
3851 2009-04-16 2009-05-09
3945 2009-04-16 2009-05-09
7274 2009-04-16 2009-05-12
7532 2009-04-16 2009-05-12
7651 2009-04-16 2009-05-12
8495 2009-04-16 2009-05-13
>

I would like to generate a 3rd column which is the difference in days
between the two dates.

I tried

a.df$DEATH - a.df$DATE

but I obtain all NA.

Any help would be much appreciated.

Thanks,
Erin



-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodgess at gmail.com



More information about the R-help mailing list