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
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
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
3 matches
Mail list logo