title: R - Cluster x number of events within y time period
body: <p>I have a dataset that has 59k entries recorded over 63 years, I need to identify clusters of events with the criteria being:</p>
  
  <p>6 or more events within 6 hours</p>
  
  <p>Each event has a unique ID, time HH:MM:SS and date DD:MM:YY, an output would ideally have a cluster ID, the eventS that took place within each cluster, and start and finish time and date.</p>
  
  <p>Thinking about the problem in R we would need to look at every date/time and count the number of events in the following 6 hours, if the number is 6 or greater save the event IDs, if not move onto the next date and perform the same task. I have taken a data extract that just contains EventID, Date, Time and Year.</p>
  
  <p><a href="https://dl.dropboxusercontent.com/u/16400709/StackOverflow/DataStack.csv" rel="nofollow">https://dl.dropboxusercontent.com/u/16400709/StackOverflow/DataStack.csv</a></p>
  
  <p>If I come up with anything in the meantime I will post below.</p>
  
  <p>Update: Having taken a break to think about the problem I have a new approach.</p>
  
  <p>Add 6 hours to the Date/Time of each event then count the number of events that fall within the start end time, if there are 6 or more take the eventIDs and assign them a clusterID. Then move onto the next event and repeat 59k times as a loop.</p>