Tom Cohen wrote:
Dear list, How can I calculate the difference in days between the eventdate and basedate in the below dataset? id basedate outcome.3 eventdate daydiff
1  1001 1999-09-28         2 1999-10-01    3
2 1002 1999-09-22 1 3 1003 2000-01-19 1 4 1004 2004-01-25 2 2004-02-03 9 5 1005 2005-08-11 1 6 1006 2000-07-04 1 2001-05-29 7 1007 2004-02-12 1 2004-11-18
8  1008 2006-01-18         2 2006-02-02
9  1009 2005-04-29         2 2005-06-14
10 1010 2006-03-17         2 2006-03-31
11 1011 2000-03-21         2 2000-03-28
12 1012 2004-07-12         1 2006-11-28
13 1013 2000-02-24 1 14 1014 2003-04-17 1 15 1015 2000-04-05 1


Given they are in some appropriate time format (e.g. when reading specify colClasses = "POSIXct" for those columns or use strptime() on the colummns later on):

difftime(x$eventdate, x$basedate, "days")

Uwe Ligges




Thanks for any help,
Tom

---------------------------------
Går det långsamt? Skaffa dig en snabbare bredbandsuppkoppling.

        [[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.

______________________________________________
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