I want to identify locations (and flag them as Anchors) where sum of duration of various activities in that location is greater than 60 minutes (or some number). However, the aggregation should be conditional - and only consider activities conducted continuously.
I cannot use the the aggregate function -
Aggdata <-aggregate(DRUG2, by=list(PersonID,Location), FUN=sum)
The above code will aggregate all activity durations in any location and unable to consider whether the activities were conducted continuously or not.
In the attached excel, Location #2 is an anchor for Person 1 because he spent >60 minutes continuously. Location #1 is not an anchor for Person 1 even though he spent a total of >60 minutes because this is not continuous.
Thanks in advance.