Re: [R] Keep only first date from consecutive dates

2015-12-04 Thread William Dunlap
With a data.frame sorted by id, with ties broken by date, as in your example, you can select rows that are either the start of a new id group or the start of run of consecutive dates with: > w <- c(TRUE, diff(uci$date)>1) | c(TRUE, diff(uci$id)!=0) > which(w) [1] 1 4 5 7 > uci[w,] id date

Re: [R] Keep only first date from consecutive dates

2015-12-04 Thread David Winsemius
> On Dec 4, 2015, at 1:10 PM, William Dunlap wrote: > > With a data.frame sorted by id, with ties broken by date, as in > your example, you can select rows that are either the start > of a new id group or the start of run of consecutive dates with: > >> w <- c(TRUE,