title: Using 2nd variable to label axis ticks in ggplot2 facets
body: <p>I am attempting to make a faceted t-chart using ggplot2, where the x-axis is represented a sequence of events and the y-axis represents the number of days between those events. The x-axis should be labelled with the event date, but it is not a time series since the distance between x-axis ticks should be uniform regardless of the real time between events. </p>
  
  <p>Adding a faceting layer has been confusing me. Here's some sample data: </p>
  
  <pre><code>df &lt;- data.frame(EventDT = as.POSIXct(c("2014-11-22 07:41:00", "2015-02-24 08:10:00",
                                    "2015-06-10 13:54:00", "2015-07-11 02:43:00",
                                    "2015-08-31 19:08:00", "2014-11-18 14:06:00",
                                    "2015-06-09 23:10:00", "2016-02-29 07:55:00",
                                    "2016-05-22 04:30:00", "2016-05-25 21:46:00",
                                    "2014-12-22 16:19:00", "2015-05-13 16:38:00",
                                    "2015-06-01 09:05:00", "2016-02-21 02:30:00",
                                    "2016-05-13 01:36:00")),
               EventNBR = rep(1:5, 3),
               Group = c(rep('A', 5), rep('B',5), rep('C',5)),
               Y = c(15.818750, 94.020139, 106.238889, 30.534028, 51.684028,
                     187.670139, 203.377778, 264.364583, 82.857639, 3.719444,
                     169.829861, 142.013194, 18.685417, 264.725694,81.962500))
  </code></pre>
  
  <p>Ignoring the date of the event, I can produce this: </p>
  
  <pre><code>g &lt;- ggplot(df, aes(x=EventNBR, y=Y)) +
    geom_point() +
    geom_line() + 
    facet_wrap(~ Group, scales='free_x')
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/1JoGp.png" rel="nofollow noreferrer">Plot should show EventDT along X-axis, not EventNBR</a></p>
  
  <p>I have tried to use the labels parameter to scale_x_discrete without success:</p>
  
  <pre><code>xaxis.ticks &lt;- function(x) {
      df[which(df$EventNBR) == x] }
  
  g + scale_x_discrete(labels = xaxis.ticks)
  </code></pre>
  
  <p>But that's wrong in a way I can't describe, because it cuts off my tick labels altogether. </p>
  
  <p>Because there is a 1-1 correspondence between EventNBR and EventDT by Group for this dataset, it seems like there should be an easy solution, but I can't figure it out. Am I overlooking something painfully easy? </p>