On 11/24/05, Martin Maechler <[EMAIL PROTECTED]> wrote: > NA's have the big drawback of producing a logical vector that > can NOT be used for subsetting -- and subsetting was exactly a main > reason for the padding... >
Since 'which' throws away NAs, one extra 'which' can solve that. In the following, runmax from caTools (which is quite fast being written in C) uses NA padding by default: x <- c(1:3, 3, 3:5, 5:1) # test data. peak is at 5. library(caTools) x.rv <- rle(x)$values x.rv[which(runmax(x.rv, 3) == x.rv)] ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
