[R] switching elements of a vector
ggrothendieck at gmail.com
Mon May 24 13:00:14 CEST 2010
> which(diff(a) > 0) + 1
 2 6 9 12 14 15
On Mon, May 24, 2010 at 6:02 AM, speretti <sabrina.peretti at gmail.com> wrote:
> I would like to receive help for the following matter:
> If I'm dealing with a numeric vectors containing increasing elements.
> There exist an efficient way to obtain an vector that indicates the position
> of the changing element of "a"?
> In this case it would be something like:
> usually I'm used cycles to obtain boolean vectors of the same length of "a"
> indicating the changing elements ...later I've muliplied them for their
> numeric sequence and after that I've selected elements different from zero
> ...it is quite long...
> can you find an easier solution?
> Thank you for you help
> View this message in context: http://r.789695.n4.nabble.com/switching-elements-of-a-vector-tp2228373p2228373.html
> Sent from the R help mailing list archive at Nabble.com.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help