title: Creating a timeline in ggplot
body: <p>Edited below with complete and functioning code:</p>
  
  <p>I am trying to create a timeline similar to the one this code creates from the Timeline package, however, the options are not very flexible.  For example, I would like to create space between each bar so they are not touching. Also, I am wondering if there is a way to add the "End_Status" column to the graph so that it it is obvious that the data stops there because the animal died.  Any help is greatly appreciated.</p>
  
  <p>Example dataset:</p>
  
  <pre><code>df &lt;- data.frame(id = c(rep(1201, 10), rep(1202, 14), rep(1203, 6),     rep(1204, 22)),
               date = c(seq(1,5,1), seq(5,7,1), seq(7,8,1), seq(2,5,1), seq(7,9,1), seq(11,17,1), seq(1,8,1), seq(8,12, 1), seq(12,26,1 )),
               schedule = as.factor(c(rep(1, 5,), rep(2, 3), rep(3, 6), 
                                   rep (1, 3), rep (2, 2), rep(3, 5),
                                   rep(1,8), rep(2, 5), rep(1,3), rep(3, 12))),
               status = c(rep("", 9), "Mort", rep("", 41), "Mort"))
  </code></pre>
  
  <p>Code to get the output table I am interested in: </p>
  
  <pre><code>library("data.table")
  library(plyr)
  library(dplyr)
  
  df&lt;-as.data.table(df)
  z &lt;- df[, unique(id)]
  ################
  value_change_first &lt;- function(x,a) { for(i in 1:length(x[,schedule])) {
  ifelse(x[a,schedule] == x[a+1,schedule], 
         x &lt;- x[-(a+1)], 
         a &lt;- a+1)}
  return(x)
  }
  
  value_change_second &lt;- function(x,a) { 
  for(i in 1:length(x[,schedule])) {
  ifelse(x[a,schedule] == x[a+1,schedule], 
         x &lt;- x[-(a)], 
         a &lt;- a+1)}
  return(x)
  }
  
  #################
  output_1 &lt;- c()
  
  for(i in 1:length(z)){
  ids &lt;- df[df$id==z[i],]
  out&lt;-value_change_first(ids,1)
  output_1&lt;-as.data.frame(rbind(output_1, out))}
  
  #################
  output_2 &lt;- c()
  
  for(i in 1:length(z)){
  ids &lt;- df[df$id==z[i],]
  out&lt;-value_change_second(ids,1)
  output_2&lt;-as.data.frame(rbind(output_2, out))}
  
  ################
  output_1$End_Date &lt;- output_2$date
  output_1$End_Status &lt;- output_2$status
  names(output_1)[names(output_1)=="date"] &lt;- "Start_Date"
  
  output &lt;- output_1[c(1:2, 5, 3, 6)]
  </code></pre>
  
  <p>From here I can use the Timeline Package to get something close to what I want:</p>
  
  <pre><code>require(timeline)
  tl &lt;- timeline(output, 
             label.col=names(output)[4],
             text.color= NA,
             group.col=names(output)[1],
             start.col=names(output)[2],
             end.col = names(output)[3])
  tl + theme_bw() + theme(panel.grid.major = element_blank(), panel.grid.minor    = element_blank())
  </code></pre>
  
  <p>My question is how to build something similar in ggplot.  Furthermore, I want to specifically add the "Mort" message at a given date by individual from the output dataframe.</p>
  
  <p>I ended up getting this to work like I want:</p>
  
  <pre><code>### creating a end status column that includes mortalities and failures
  output$End_Status_Date&lt;-NA
  for(i in 1:nrow(output)){
  if(output$End_Status[i] == "Mort"){
  output$End_Status_Date[i]=as.character(output$End_Date)[i] 
  }
  }
  
  for(i in 1:nrow(output)){
  if(output$End_Status[i] == "Failure"){
  output$End_Status_Date[i]=as.character(output$End_Date)[i] 
  }
  }
  
  ### data structuring
  output$id&lt;-as.factor(output$id)
  output$End_Status_Date&lt;-as.numeric(output$End_Status_Date)
  output$End_Status[output$End_Status == ""] &lt;- NA
  output$End_Status&lt;-as.character(output$End_Status)
  output$End_Status&lt;-as.factor(output$End_Status)
  
  library(ggplot2)
  
  g2 &lt;- ggplot() +
  geom_segment(data=output, aes(x=Start_Date, xend=End_Date, y=id, yend=id,    color=schedule), linetype=1, size=2) +
  geom_point(data=subset(output, is.na(End_Status)==FALSE), 
           mapping=aes(x=End_Status_Date, y=id, shape=End_Status,   fill=End_Status), size=4)+
  scale_colour_manual(values=c("blue4", "chartreuse4", "darkmagenta"))+
  scale_fill_manual(values=c("white", "red"))+ 
  scale_shape_manual(values=c(21,24))+ 
  xlab("Time")+
  ylab("Individuals")+
  theme_bw() + theme(panel.grid.minor = element_blank(), panel.grid.major =   element_blank())
  
  g2
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/sBiYL.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sBiYL.jpg" alt="Timeline Example"></a></p>