skip to main
|
skip to sidebar
R Tricks
Monday, July 23, 2007
Run Length
A small function to get runlength from a vector
runlength=function(x){
run=1
k=1
for( i in 2: length(x)){
if(x[i]==x[i-1]) run[k]=run[k]+1
else{
k=k+1
run=c(run,1)
}
}
return(run)
}
Newer Posts
Older Posts
Home
Subscribe to:
Posts (Atom)
Blog Archive
►
2011
(2)
►
July
(2)
▼
2007
(4)
▼
July
(1)
Run Length
►
April
(3)
About Me
surajit.ray
View my complete profile