AM
To: r-help@r-project.org
Subject: [R] switching elements of a vector
Hi,
I would like to receive help for the following matter:
If I'm dealing with a numeric vectors containing increasing elements.
i.e.
a<-c(1,2,2,2,2,3,3,3,4,4,4,5,5,6,7,7,7)
There exist an efficient way to o
it works as well!
--
View this message in context:
http://r.789695.n4.nabble.com/switching-elements-of-a-vector-tp2228373p2228485.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/m
Thank you !
Great answers...now it seems very easy...
As usual...a the obviousness of a solution depends on how you face the
problem...
Thank you for help me in find the good approaches...
--
View this message in context:
http://r.789695.n4.nabble.com/switching-elements-of-a-vector-tp2228373p2
Try this:
> which(diff(a) > 0) + 1
[1] 2 6 9 12 14 15
On Mon, May 24, 2010 at 6:02 AM, speretti wrote:
>
> Hi,
>
> I would like to receive help for the following matter:
>
> If I'm dealing with a numeric vectors containing increasing elements.
> i.e.
>
> a<-c(1,2,2,2,2,3,3,3,4,4,4,5,5,6,7,7,
Hi,
is this what you need?
b <- c(NA, a[1:length(a)-1]) # shift values of a one step to the right
which(a-b == 1)
On Monday 24 May 2010 12:02:55 pm speretti wrote:
> Hi,
>
> I would like to receive help for the following matter:
>
> If I'm dealing with a numeric vectors containing increasin
On 5/24/2010 6:02 AM, speretti wrote:
> Hi,
>
> I would like to receive help for the following matter:
>
> If I'm dealing with a numeric vectors containing increasing elements.
> i.e.
>
> a<-c(1,2,2,2,2,3,3,3,4,4,4,5,5,6,7,7,7)
>
> There exist an efficient way to obtain an vector that indicate
Hi,
I would like to receive help for the following matter:
If I'm dealing with a numeric vectors containing increasing elements.
i.e.
a<-c(1,2,2,2,2,3,3,3,4,4,4,5,5,6,7,7,7)
There exist an efficient way to obtain an vector that indicates the position
of the changing element of "a"?
In this ca
7 matches
Mail list logo