I don\'t think this question has asked yet (most similar questions are about extracting data or returning a count). I am new to R, so any help would be appreciated!
Here is my code. I will post the explanation in some time.
require(plyr)
ddply(Data, .(ID), summarize, timeToEQ = Position(isTRUE, abs(diff(CC)) < 0.05 ))
ID timeToEQ
1 1 3
2 2 2
EDIT. Here is how it works.
ddply
breaks Data
into subsets based on ID
. diff(CC)
computes the difference between CC
of successive rows.abs(diff(CC)) < 0.05)
returns TRUE if the difference has stabilized.Position
locates the first instance of an element which satisfies isTRUE
.