Typing "?" (no quotes) followed by a topic of interest will throw up the R Help documentation. 1. Have a look at ?runif 2. Try ?subset and ?cumsum 3. Look at ?rle. Use in conjunction with cumsum and maybe ifelse. HTH Pete -- View this message in context: http://r.789695.n4.nabble.com/Help-plz-tp3247449p3247576.html Sent from the R help mailing list archive at Nabble.com.