[R] Cleaning date columns

Newbie19_02 nvanzuydam at gmail.com
Wed Mar 9 12:20:18 CET 2011


Hi Everyone,

I have the following problem:

data <- structure(list(prochi = c("IND1", "IND1", "IND1", 
"IND2", "IND2", "IND2", "IND2", "IND3", 
"IND4", "IND5"), date_admission = structure(c(6468, 
6470, 7063, 9981, 9983, 14186, 14372, 5129, 9767, 11168), class = "Date")),
.Names = c("prochi", 
"date_admission"), row.names = c("27", "28", "21", "86", "77", 
"80", "1", "114", "192", "322"), class = "data.frame")


I have records for individuals that were taken on specific dates.  Some of
the dates are within 3 days of each other.  I want to be able to clean my
date column and select the earliest of the dates that occur within 3 days of
each other per individual as a single observation that represents the N
observations.  So for example:

input:
IND1    1987-09-17
IND1     1987-09-19
IND1     1989-05-04

output:
IND1    1987-09-17
IND1     1989-05-04

I'm  not sure where to start with this?

Thanks,
Nat
 

--
View this message in context: http://r.789695.n4.nabble.com/Cleaning-date-columns-tp3343359p3343359.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list