I have a data frame that is 122 columns and 7ish rows it is a zoo
object, but could be easily converted or read in as something else. It is
multiparameter multistation water quality data - there are a lot of NA s. I
would like to find chuncks of data that are free of NA s to do some
na.contiguous.zoo() will return the longest stretch of non-NA data.
Its a zoo method of the na.contiguous generic in the core of R.
rle(!is.na(rowSums(coredata(z will find all stretches.
On Fri, Jul 18, 2008 at 6:47 AM, stephen sefick [EMAIL PROTECTED] wrote:
I have a data frame that is 122
#how do I use the below, sorry for being unsavey. I would look for when
value = FALSE meaning the there are no NAs and Then look for the longest
value of continuous measurements (or lengths that I am comfortable with)
correct? How do I subset my original data frame with this information? How
do
It would be appreciated if you cut down your data to
a minimal size before posting. At any rate, the ends
are the cumsums of the lengths and
the starts are lengths-1 before that, e.g.
# data
library(zoo)
z - zoo(c(1, 2, NA, 3, 4, 5, NA, 6))
z - cbind(z, z)
z.rle -
minimal, minimal, minimal, I will have to remind myself.
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 -
5 matches
Mail list logo