title: How to add legend to ggplot2 line chart?
body: <p>I have a simple dataframe:</p>
  
  <pre>> ih
    year    y1    y2
  1 2005  4.50  4.92
  2 2006  4.89  6.21
  3 2007  6.63  6.68
  4 2008  4.89  4.60
  5 2009 16.56 15.16
  6 2010 17.98 17.73
  7 2011 25.92 19.85</pre>
  
  <p>And I would like to graph a line chart with year on the x-axis and y1 and y2 as two separate lines, both black and with different line types. How can I get a legend that shows that y1 represents "Bob" and y2 represents "Susan"?</p>
  
  <p>Here is my attempt, which produces the following graph (without a legend):</p>
  
  <pre><code>ggplot(ih, aes(x = year)) + geom_line(aes(y=y1), linetype="dashed") + 
    geom_line(aes(y=y2)) + 
    labs(x="Year", y="Percentage", fill="Data") + 
    geom_point(aes(y=y1)) + 
    geom_point(aes(y=y2))
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/6sHAU.png" alt="enter image description here"></p>
  
  <p>Thank you for any help! Today is my first day using R!</p>