Displaying 1 result from an estimated 1 matches for "findruns".
2012 Jul 11
1
browser() question
All,
How come i=1 in the first case, but i=2 in the second case. The second case
seems to work, but the first case does not.
David.
> findruns <- function(x,k) {
+ n <- length(x)
+ runs <- NULL
+ for (i in 1:(n-k+1)) {
+ if (all(x[i:(i+k-1)]==1)) runs <- c(runs,i)
+ browser(i>1)
+ }
+ return(runs)
+ }
> x=c(1,1,0,0,1,1,1)
> findruns(x,2)
Called from: findruns(x, 2)
Browse[1]> i
[1] 1
Browse[1]>...