title: Interaction plot with confidence intervals
body: <p>I want to draw an interaction plot with confidence intervals for an assignement that is due tomorrow. This is my dataset:</p>
  
  <pre><code>Snail0
  
      water   lightness   total_migration
      control dark    9.5
      control dark    20
      control dark    22
      control dark    24
      control dark    10
      control dark    18
      control dark    19
      control dark    19.5
      control dark    23
      control dark    2
      control dark    10.5
      control dark    22.5
      control dark    26
      control dark    32
      control dark    2
      control dark    12.5
      control dark    13.5
      control dark    16.5
      control dark    19
      control dark    20
      control dark    21
      control dark    22
      control dark    24
      control dark    25
      control light   11
      control light   20.5
      control light   22.5
      control light   24
      control light   21
      control light   23
      control light   23.5
      control light   28
      control light   30
      control light   18.5
      control light   19.5
      control light   19.5
      control light   23.5
      control light   24
      control light   2
      control light   20
      control light   23
      control light   28.5
      control light   29
      control light   16
      control light   17.5
      control light   26.5
      control light   28.1
      control light   30.5
      crab    light   6
      crab    light   14
      crab    light   15
      crab    light   17
      crab    light   19
      crab    light   7
      crab    light   14
      crab    light   17
      crab    light   22
      crab    light   26
      crab    light   4.5
      crab    light   10
      crab    light   11
      crab    light   21
      crab    light   24
      crab    light   14
      crab    light   20
      crab    light   22.5
      crab    light   23
      crab    light   14
      crab    light   16
      crab    light   18.5
      crab    light   22
      crab    light   23
      crab    dark    14
      crab    dark    19
      crab    dark    20
      crab    dark    23
      crab    dark    25
      crab    dark    9
      crab    dark    18
      crab    dark    18
      crab    dark    20
      crab    dark    21
      crab    dark    15
      crab    dark    15
      crab    dark    15
      crab    dark    19
      crab    dark    23
      crab    dark    12
      crab    dark    14.5
      crab    dark    21
      crab    dark    21.5
      crab    dark    22
      crab    dark    14.5
      crab    dark    16
      crab    dark    19
      crab    dark    20
      crab    dark    22.5
      snail   dark    6
      snail   dark    15
      snail   dark    20
      snail   dark    22
      snail   dark    15
      snail   dark    15
      snail   dark    16
      snail   dark    17
      snail   dark    21
      snail   dark    15
      snail   dark    20
      snail   dark    15
      snail   dark    16
      snail   dark    19.5
      snail   dark    23
      snail   dark    24
      snail   dark    4
      snail   dark    18.5
      snail   dark    20
      snail   dark    24
      snail   dark    25
      snail   light   13
      snail   light   13
      snail   light   13
      snail   light   18
      snail   light   15
      snail   light   16
      snail   light   17
      snail   light   17
      snail   light   19
      snail   light   14
      snail   light   14
      snail   light   19
      snail   light   7
      snail   light   13
      snail   light   13
      snail   light   13
      snail   light   16
      snail   light   3
      snail   light   9
      snail   light   15
      snail   light   22
      snail   light   23
  </code></pre>
  
  <hr>
  
  <pre><code>interaction.plot(Snail0$water,Snail0$lightness,Snail0$total_migration) 
  </code></pre>
  
  <p>I have been trying to do something like what is done at the bottom here with the <a href="https://stats.stackexchange.com/questions/9477/how-to-draw-an-interaction-plot-with-confidence-intervals">ToothGrowth data</a>, but I am obviously doing something wrong as I only get error messages.</p>
  
  <pre><code>Snail0$water &lt;- factor(Snail0$water)
  
  
  df&lt;-with(Snail0, aggregate(total_migration, list(lightness=lightness, water=water), mean))
  
  
  df$se&lt;-with(Snail0, aggregate(total_migration, list(lightness=lightness, water=water), function(x) sd(x)/sqrt(10)))[,3]
  
  
  gp&lt;-ggplot(df, aes(x=water, y=total_migration, colour=lightness, group=lightness))
  
  gp+geom_line(aes(linetype=lightness)) + geom_point(aes(shape=lightness)) + geom_errorbar(aes(ymax=x+se, ymin=x-se))
  </code></pre>
  
  <p>Error message:</p>
  
  <pre><code>Error: Aesthetics must either be length one, or the same length as the dataProblems:lightness, water, lightness, lightness
  </code></pre>
  
  <p>Obviously, I have no idea what I'm doing, so can anyone please help me correct my code?</p>