On Thu, 30 Mar 2006, Wuming Gong wrote: > Dear list, > > Given a vector of logical values, say > > >a <- c(TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE) > > Are there any R functions that can tell whether there are two or more > "TRUE" in a row in this vector?
?rle (a very useful function) aa <- rle(a) any(aa$values & aa$lengths > 1) > > Thanks, > > Wuming > > ______________________________________________ > [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 > -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: [EMAIL PROTECTED] ______________________________________________ [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
