title: Extracting Date specific variable changes and plotting on timeline by ID
body: <p>I am trying to extract the dates at which a factor value changes (by unique IDs) so that I can plot across a timeline.</p>
  
  <p>At this point, I am having a hard time extracting the data from the original data frame to even start producing the timeline.</p>
  
  <p>An example data set would look something like this: </p>
  
  <pre><code>df &lt;- data.frame(id = c(rep(1201, 10), rep(1202, 14)),
                  date = c(seq(1,10,1), seq(2,15,1)),
                  value = as.factor(c(rep(1, 5,), rep(2, 3), rep(3, 6), rep (1, 3), rep (2, 2), rep(3, 5))))
  </code></pre>
  
  <p>In which I have a sequence of dates which at some point, the factor variable (in this case "value) changes.  I need to extract the start and end date within each individual so that I can plot those across a timeline. </p>
  
  <p>In this case, I would end up with a product that looks like:</p>
  
  <pre><code>out &lt;- data.frame (id = c(rep(1201, 3), rep(1202, 4)), 
                 date = c(1, 6, 9, 2, 6, 9, 11),
                 value = c(1, 2, 3, 3, 1, 2, 3))
  </code></pre>
  
  <p>From there, I would want to plot some form of timeline with each ID on the y-axis and date across the x-axis. What I envision is a horizontal bar graph where the color changes dependent on the value field. This way, you can visualize when each individual was on the same value across time. </p>
  
  <p>Any help really is appreciated!</p>