[R] Detecting Break

2009-07-05 Thread Arun Kumar Saha
Hi all, say, I have following vector : x - c(rep(5, 5), rep(3,4), rep(5,10)) Now I want to get the index numbers where elements of that vector changes i.e. in above example I want to get a vector with elements : 6, 10. Because at that indices, element of original vector changes value. Is there

Re: [R] Detecting Break

2009-07-05 Thread Henrique Dallazuanna
Try this: which(c(0, diff(x)) != 0) On Sun, Jul 5, 2009 at 4:03 PM, Arun Kumar Saha arun.kumar.s...@gmail.comwrote: Hi all, say, I have following vector : x - c(rep(5, 5), rep(3,4), rep(5,10)) Now I want to get the index numbers where elements of that vector changes i.e. in above

Re: [R] Detecting Break

2009-07-05 Thread Don MacQueen
You can also derive what you need using the rle() function, though the which() solution may be easier. -Don At 4:20 PM -0300 7/5/09, Henrique Dallazuanna wrote: Content-Type: text/plain Content-Disposition: inline Content-length: 944 Try this: which(c(0, diff(x)) != 0) On Sun, Jul 5,