title: Plotting lines and the group aesthetic in ggplot2
body: <p>This question follows on from an earlier <a href="https://stackoverflow.com/questions/10349096/group-data-and-plot-multiple-lines-in-r">question and its answers.</a> </p>
  
  <p>First some toy data:</p>
  
  <pre><code>df = read.table(text = 
  "School      Year    Value 
   A           1998    5
   B           1999    10
   C           2000    15
   A           2000    7
   B           2001    15
   C           2002    20", sep = "", header = TRUE)
  </code></pre>
  
  <p>The original question asked how to plot Value-Year lines for each School. The answers more or less correspond to p1 and p2 below. But also consider p3. </p>
  
  <pre><code>library(ggplot2)
  
  (p1 &lt;- ggplot(data = df, aes(x = Year, y = Value, colour = School)) +       
     geom_line() + geom_point())
  
  (p2 &lt;- ggplot(data = df, aes(x = factor(Year), y = Value, colour = School)) +       
    geom_line(aes(group = School)) + geom_point())
  
  (p3 &lt;- ggplot(data = df, aes(x = factor(Year), y = Value, colour = School)) +       
    geom_line() + geom_point())
  </code></pre>
  
  <p>Both p1 and p2 do the job. The difference between p1 and p2 is that p1 treats <code>Year</code> as numeric whereas p2 treats <code>Year</code> as a factor.  Also, p2 contains a <code>group</code> aesthetic in <code>geom_line</code>. But when the <code>group</code> aesthetic is dropped as in p3, the lines are not drawn.</p>
  
  <p>The question is: Why is the <code>group</code> aesthetic necessary when the x-axis variable is a factor but the <code>group</code> aesthetic is not needed when the x-axis variable is numeric?</p>
  
  <p><img src="https://i.stack.imgur.com/mo2od.png" alt="enter image description here"></p>