Skip to content
Back to formatted view

Raw Message

Message-ID: <1294999065143-3217385.post@n4.nabble.com>
Date: 2011-01-14T09:57:45Z
From: Taras Zakharko
Subject: Selecting the first occurrence of a value after an occurrence of a different value
In-Reply-To: <1294996946647-3217340.post@n4.nabble.com>

Hi,

 I'll do something like this (there is probably a nicer way, but this code
is what first comes up to my mind)

 provided your data is in x

 pos1 <- which(x %in% val1)[1]
 pos2  <- which(x %in% val2)[which(x %in% val2) >  pos1][1]

 
-- 
View this message in context: http://r.789695.n4.nabble.com/Selecting-the-first-occurrence-of-a-value-after-an-occurrence-of-a-different-value-tp3217340p3217385.html
Sent from the R help mailing list archive at Nabble.com.