title: Rollapply in for loop
body: <p>So, what I am doing is creating a heatmap for <code>x</code> and <code>y</code> coordinates. But I would like to do this for every 30 minute interval. For example the first heatmap will be created using the data from <code>"00:00:00"</code> to <code>"00:30:00"</code>, then the next from <code>"00:01:00"</code> to <code>"00:31:00"</code>.</p>
  
  <p>What I need help with is writing a for loop that can extract these rows from a larger database and then spit out the heatmap for each bracket of data. I have been told that <code>zoo::rollapply</code> could be useful in the process but am not sure how it works.</p>
  
  <p>The database has three columns <code>x</code>, <code>y</code>, and <code>indiv.times</code>. <code>x</code> and <code>y</code> are the coordinate systems and <code>indiv.times</code> is a character variable which contains the times in the format <code>"13:04:46"</code> for example.</p>
  
  <pre><code>for (i in ???) {
    kde &lt;- kde2d(x, y)
    plot_ly(z = kde$z, type = "heatmap")
  }
  </code></pre>
  
  <p>This is the code to create the heatmap so I really just need a way to extract the 30 minute intervals.</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Here is a sample of the database:</p>
  
  <pre><code>structure(list(x = c(224.7666, 223.3886, 131.7025, 345.333), 
      y = c(60.7657, 85.73872, 77.35342, 26.24607), indiv.times = Sys.time() +
      cumsum(60*sample(20, size = 10, replace = TRUE)), class = "data.frame", row.names = c(NA, -4L)))
  </code></pre>