title: time block coverage heat map data reshaping
body: <p>I am trying to create a heat map using a very weird data structure</p>
  
  <p>you can generate some sample data (admittedly very inefficient) with the following code:</p>
  
  <pre><code>times&lt;-sort(format(seq.POSIXt(as.POSIXct(Sys.Date()),as.POSIXct(Sys.Date()+1),by = "5 min"),"%H%M"))
  set.seed(922)
  sample.data&lt;-as.data.frame(matrix(NA,nrow = 2000,ncol = 10))
  names(sample.data)&lt;-c("INDEX","DAY1","START1","END1","DAY2","START2","END2","DAY3","START3","END3")
  for(i in 1:nrow(sample.data)){
    sample.data[i,"INDEX"]&lt;-sample(1:100,1,replace = T)
    sample.data[i,"DAY1"]&lt;-sample(c("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"),1,replace = F)
    sample.data[i,"START1"]&lt;-sample(times,1,replace = T)
    sample.data[i,"END1"]&lt;-sample(times,1,replace = T)
    sample.data[i,"DAY2"]&lt;-sample(c("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"),1,replace = F)
    sample.data[i,"START2"]&lt;-sample(times,1,replace = T)
    sample.data[i,"END2"]&lt;-sample(times,1,replace = T)
    sample.data[i,"DAY3"]&lt;-sample(c("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"),1,replace = F)
    sample.data[i,"START3"]&lt;-sample(times,1,replace = T)
    sample.data[i,"END3"]&lt;-sample(times,1,replace = T)
  }
  
  data&lt;-sample.data%&gt;%
    filter(START1&lt;END1 &amp; START2&lt;END2 &amp; START3&lt;END3 &amp; DAY1!=DAY2 &amp; DAY1!=DAY3 &amp; DAY2!=DAY3)
  </code></pre>
  
  <p>I know it's ugly and inefficient, but the data is roughly in this structure. You can think of this as the number of employees you have say at the airport at any given time where each row is the employees'  shift times.</p>
  
  <p>I want to create a heatmap with time of day broken into 5 minute segments on the y-axis, and Days of the Week on the x axis. Do I have to gather the columns and group by 5 minute time chunks? I have no clue.</p>
  
  <p>If the data were in the right structure, I could group by weekday and the distinct 5 minute chunks, and tally every row where there was a observational unit at the airport. I just don't know how I'm going to get dplyr to say there's a person working without explicitly calling it out, and I don't know how to do that without a for loop. If I need to explain what I'm going for better, or if you have any bright ideas of how to get my data in the right form or if I'm even thinking about this in the right way, let me know. I've been banging my head against the desk, and I need to step away from the problem for a minute, but if it helps the heat map should come out if you execute the following plot code:</p>
  
  <pre><code>ggplot(data, aes(x = DAY, y = TIME_CHUNK))+
  geom_tile(aes(fill = TOTAL_EMPLOYEES))+
  geom_text(aes(label = TOTAL_EMPLOYEES), colour = "white",size = 3)
  </code></pre>
  
  <p>Thanks for your time...</p>