On Sun, Jan 16, 2011 at 11:09:58PM -0800, surreyj wrote:
Hello,
Back again,
I thought the problem was solved but I realised that the only reason I was
getting the correct answer was because my data set happened to only have two
rfts to choose from, so it looked correct.
I have been
Hi Freddy,
I have a long column of event codes e.g. below (in multiple files) that I am
trying to analyse.
OutMag
FirstResp
InMag
MagUp
OutMag
MagDwn
Resp
Resp
Resp
InMag
MagUp
OutMag
InMag
OutMag
InMag
OutMag
InMag
OutMag
InMag
MagDwn
OutMag
Resp
MagUp
InMag
MagDwn
OutMag
Resp
MagUp
With
Thanks so Peter, works great!
Surrey
--
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-tp3217340p3221271.html
Sent from the R help mailing list archive at Nabble.com.
Hello,
Back again,
I thought the problem was solved but I realised that the only reason I was
getting the correct answer was because my data set happened to only have two
rfts to choose from, so it looked correct.
I have been using:
Thanks so much for your help everyone, got it sorted now :)
this is what I used in the end:
timeofonlyfirstresponseafterrft-testdata$Time[test-which(!diff(as.numeric(factor(Stat,
levels = c(MagDwn, Resp)]
timeofonlyfirstresponseafterrft1-as.POSIXct(timeofonlyfirstresponseafterrft,
Hello everyone,
I am currently working with some data where I need to select the first
occurrence of a value after the occurrence of another value.
The data has two columns, one with a time and one with occurence of certain
events.
The column of data I want to select from looks like this
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:
Try this:
which(x %in% c(MagDwn, Resp))[2]
On Fri, Jan 14, 2011 at 7:22 AM, surreyj surreyjack...@gmail.com wrote:
Hello everyone,
I am currently working with some data where I need to select the first
occurrence of a value after the occurrence of another value.
The data has two
Other option:
which(!diff(as.numeric(factor(x, levels = c(MagDwn, Resp)[1]
On Fri, Jan 14, 2011 at 10:12 AM, Henrique Dallazuanna www...@gmail.comwrote:
Try this:
which(x %in% c(MagDwn, Resp))[2]
On Fri, Jan 14, 2011 at 7:22 AM, surreyj surreyjack...@gmail.com wrote:
Hello
Thanks so much that works, but I just realised I was unclear, I meant I need
to select all the MagDwn after every Resp :)
--
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-tp3217340p3217456.html
Sent
Ofcourse you can loop over your data, but a vectorised way:
f.search - function(x, ref, search) {
cs - match(cumsum(x==ref), cumsum(x==ref))
outp - suppressWarnings(tapply(x==search,cs, function(x)
min(which(x==1
outp - outp[outp!=Inf] # To remove the occurences where nothing was
11 matches
Mail list logo