title: Using ggplot in R to create a line graph for two different groups
body: <p>I'm trying to create a line graph depicting different trajectories over time for two groups/conditions. I have two groups for which the data 'eat' was collected at five time points (1,2,3,4,5). 
  I'd like the lines to connect the mean point for each group at each of five time points, so I'd have two points at Time 1, two points at Time 2, and so on.</p>
  
  <p>Here's a reproducible example:</p>
  
  <pre><code>#Example data
  library(tidyverse)
  library(ggplot2)
  eat &lt;- sample(1:7, size = 30, replace = TRUE)
  df &lt;- data.frame(id = rep(c(1, 2, 3, 4, 5, 6), each = 5),
                   Condition = rep(c(0, 1), each = 15),
                   time = c(1, 2, 3, 4, 5),
                   eat = eat
  )
  df$time &lt;- as.factor(df$time)
  df$Condition &lt;- as.factor(df$Condition)
  
  #Create the plot.
  library(ggplot2)
  ggplot(df, aes(x = time, y = eat, fill = Condition)) + geom_line() +
    geom_point(size = 4, shape = 21) +
    stat_summary(fun.y = mean, colour = "red", geom = "line")
  </code></pre>
  
  <p>The problem is, I need my lines to go horizontally (ie to show two different colored lines moving across the x-axis). But this code just connects the dots vertically:</p>
  
  <p><img src="https://i.stack.imgur.com/gh805.png" alt="Here&#39;s what it looks like:"></p>
  
  <p>If I don't convert <code>Time</code> to a factor, but only convert <code>Condition</code> to a factor, I get a mess of lines. The same thing happens in my actual data, as well. </p>
  
  <p><img src="https://i.stack.imgur.com/fy6Rd.png" alt="example graph result"></p>
  
  <p>I'd like it to look like this <img src="https://i.stack.imgur.com/PjtGr.png" alt="like this"> aesthetically, with the transparent error envelopes wrapping each line.  However, I don't want it to be curvy, I want the lines to be straight, connecting the means at each point.</p>