Re: [R] Looping, Control Flow & Conditional Statements

2008-06-13 Thread Garth.Warren
Thanks Chuck, 'rle' was just what I needed. G -Original Message- From: Charles C. Berry [mailto:[EMAIL PROTECTED] Sent: Saturday, 14 June 2008 02:00 To: Warren, Garth (CSE, Gungahlin) Cc: r-help@r-project.org Subject: Re: [R] Looping, Control Flow & Conditional Sta

Re: [R] Looping, Control Flow & Conditional Statements

2008-06-13 Thread Charles C. Berry
See ?rle Start with this: a1.runs <- rle( a1 ) a1.runs$lengths[ a1.runs$values>0 ] [1] 3 4 HTH, Chuck p.s. library(fortunes) fortune(106) If the answer is parse() you should usually rethink the question. -- Thomas Lumley R-help (February 2005) -- see ?ge

[R] Looping, Control Flow & Conditional Statements

2008-06-13 Thread Garth.Warren
Dear R Group: I have little experience using R and even less experience with control flow type questions. See the following code: a1 = c(0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0) for(i in 1:1){ sx <- paste("a",i,sep="") s <- eval(parse(text = paste("a