That's exactly what I was thinking. Thanks tons.
Sent from Yahoo Mail on Android
From:"arun"
Date:Sun, Feb 15, 2015 at 2:47 AM
Subject:Re: Difference in dates for unique ID
HI Farnoosh,
Not sure I understand the expected output.� The difference between the first 2
days is "136 days"
May be
HI Farnoosh,
Not sure I understand the expected output. The difference between the first 2
days is "136 days"
May be this helps
library(data.table)
dcast.data.table(setDT(df)[, list(Visit=.N, Diff=
as.numeric(abs(diff(as.Date(Date, format='%d-%b-%y') ,
by = ID], ID+Vi
Are you sure your data was the Date class?
> x <- read.table('clipboard', header=TRUE)
> x
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 20
227.1901 days
> 9 2010-12-24 2009-07-19 523.5030 days
> 10 2010-09-25 2009-06-27 454.6529 days
>
> generates differences between the 2 columns without NAs.
> What's the output you get when you call str on your data frame?
>
> Christos
>
>
>> Date: Sun, 20 Jun
9 2010-12-24 2009-07-19 523.5030 days
10 2010-09-25 2009-06-27 454.6529 days
generates differences between the 2 columns without NAs.
What's the output you get when you call str on your data frame?
Christos
> Date: Sun, 20 Jun 2010 19:13:24 -0500
> From: erinm.hodg...@gmail.com
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
6 matches
Mail list logo