Re: [R] Difference in dates for unique ID

2015-02-15 Thread farnoosh sheikhi via R-help
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

Re: [R] Difference in dates for unique ID

2015-02-15 Thread arun
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