Skip to content

browser() question

3 messages · David Arnold, Sarah Goslee, R. Michael Weylandt

#
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.
+   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)
+ }
Called from: findruns(x, 2)
Browse[1]> i
[1] 1
Browse[1]> Q
+   n <- length(x)
+   runs <- NULL
+   for (i in 1:(n-k+1)) {
+     if (all(x[i:(i+k-1)]==1)) runs <- c(runs,i)
+     if (i>1) browser()
+   }
+   return(runs)
+ }
Called from: findruns(x, 2)
Browse[1]> i
[1] 2
Browse[1]> 

--
View this message in context: http://r.789695.n4.nabble.com/browser-question-tp4636104.html
Sent from the R help mailing list archive at Nabble.com.
#
Incidentally, the OP might want to take a look at ?rle. 

Michael
On Jul 11, 2012, at 3:42 AM, Sarah Goslee <sarah.goslee at gmail.com> wrote: