(I have modified this question to make it more explicit.)
I have a dataset as follows:
data <- structure(list(id = 1:12, personID = c(1L, 2L, 3L, 4L, 4L, 3L,
2L, 1L, 1L, 2L, 3L, 4L), lastName = structure(c(1L, 2L, 3L, 4L,
4L, 3L, 2L, 1L, 1L, 2L, 3L, 4L), .Label = c("james", "joan",
"lucy", "mary"), class = "factor"), date = structure(c(5L, 5L,
8L, 9L, 6L, 1L, 3L, 11L, 4L, 2L, 7L, 10L), .Label = c("1/01/2012",
"10/04/2011", "11/01/2012", "11/08/2011", "12/01/2012", "12/04/2012",
"12/12/2011", "14/01/2012", "16/01/2012", "24/06/2010", "24/06/2011"
), class = "factor"), status = c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 2L, 1L, 2L, 1L)), .Names = c("id", "personID", "lastName",
"date", "status"), class = "data.frame", row.names = c(NA, -12L
))
I need to extract a subset from the data frame to include records where each row occured more than once in a period of greater than 8 weeks.
The extraction needs to search from the oldest record and then select the next (more recent) additional record for the same personID that was greater then 8 weeks since the previous record. Upon finding another record older then 8 weeks it should repeat the process using what the more recent second record as the new starting point.
Thanks.
How about: