Skip to content
Back to formatted view

Raw Message

Message-ID: <1342550440673-4636786.post@n4.nabble.com>
Date: 2012-07-17T18:40:40Z
From: APOCooter
Subject: Script help: Determining Time Difference between two data	points.
In-Reply-To: <E66794E69CFDE04D9A70842786030B932DA4F1@PA-MBX01.na.tibco.com>

Yes!  That does exactly what I want it to.  Thank you so much.

One question, though, is it possible that the time difference be in hours
instead of seconds (other than dividing by 3600)?  Looking at the code, I
don't know what I would change.

Does this do what you want? 
  > firstInRun <- function(x) c(TRUE, x[-1] != x[-length(x)]) 
  > lastInRun <- function(x) c(x[-1] != x[-length(x)], TRUE) 
  > f <- function(data, condition) { 
  +     with(data, data.frame(startDate = Date[firstInRun(condition)], 
  +                           endDate = Date[lastInRun(condition)])) 
  + } 
  > f(d, d$Score > 150) 

--
View this message in context: http://r.789695.n4.nabble.com/Script-help-Determining-Time-Difference-between-two-data-points-tp4636743p4636786.html
Sent from the R help mailing list archive at Nabble.com.