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
> 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,
2 matches
Mail list logo