R/contiguous.zoo.R

Defines functions `contiguous.zoo`

`contiguous.zoo` <- function(x)
{
z.rle <- rle(!is.na(rowSums(coredata(x))))
# row indexes
ends <- cumsum(z.rle$lengths)
starts <- ends - z.rle$lengths + 1
indexes <- with(z.rle, data.frame(starts, ends, lengths, values))
indexes.sort <- indexes[order(-indexes$lengths), ]
indexes.sort[indexes.sort$values, ]
}

Try the StreamMetabolism package in your browser

Any scripts or data that you put into this service are public.

StreamMetabolism documentation built on May 2, 2019, 1:08 p.m.