Skip to content
Prev 320278 / 398506 Next

Newbie code to count runs of up or down moves

Debugging nested loops is something we try to avoid in R, because there are usually more efficient ways to accomplish things.

Does this do what you want?

hist(rle(diff(z)<0)$lengths)
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.
Newbie1234 <larry at riskengineer.com> wrote: