[R] count length of continues elements in a vector

davetracz drtracz at ucalgary.ca
Tue Jun 7 16:25:29 CEST 2011


I am performing a precipitation analysis. data is in the form of daily
precipitation amounts, e.g.

x<- c(4,5,3,0,0,0,2,4,6,4,0,0,0,2,2,0,3,4,1,0,...)

I would like to find the length of the "storm", length of storm would be
defined as the number of days with continues precipitation. in this case the
returned vector would be:

 (3,4,2,3,...)

I would also like the amount of precipitation associated with each "storm"
in another variable. in this case the variable would look like:

(12,16,4,8,...)

any suggestions would be appreciated.

thanks
Dave

--
View this message in context: http://r.789695.n4.nabble.com/count-length-of-continues-elements-in-a-vector-tp3579754p3579754.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list