Re: [R] Obtaing the maximum

2013-05-30 Thread arun
rnag...@gmail.com; smartpink...@yahoo.com; r-help@r-project.org Cc: R help Sent: Thursday, May 30, 2013 1:06 PM Subject: Re: [R] Obtaing the maximum Hi, or ... a shorter way would be: a1<-c(1,2,3,4,5,1,2,3,1,1,1,2,3,4,5,1,2,3) a1[c(which(diff(a1)!=1),length(a1))] Hope it helps. Marion Ge

Re: [R] Obtaing the maximum

2013-05-28 Thread arun
Hi, May be this helps: a1<-c(1:5,1:3,rep(1,2),1:5,1:3)  a1 # [1] 1 2 3 4 5 1 2 3 1 1 1 2 3 4 5 1 2 3 a1[sort(c(which(c(diff(a1)<0,TRUE)), which(a1[-length(a1)] == a1[-1])))] #[1] 5 3 1 1 5 3 a2<-c(1:2,rep(1,4),1:7,1:3) a2 # [1] 1 2 1 1 1 1 1 2 3 4 5 6 7 1 2 3  a2[sort(c(which(c(diff(a2)<0,TRUE)),

[R] Obtaing the maximum

2013-05-28 Thread Trying To learn again
Hi all, I have a series whose tpe for that is like series I expose below. The thing is if a incremental number ends I´m in the first "type" of event in this success is named 5 (because of the maximum is 5). In the series I have this kind of events 5,3,1,1,5,3 But I don´t know extactly a priori w