title: ggplot2 change line type
body: <p>I've been trying to plot two line graphs, one dashed and the other solid. I succeeded in doing so in the plot area, but the legend is problematic. </p>
  
  <p>I looked at posts such as <a href="https://stackoverflow.com/questions/14875582/changing-the-line-type-in-the-ggplot-legend">Changing the line type in the ggplot legend</a> , but I can't seem to fix the solution. Where have I gone wrong? </p>
  
  <pre><code>library(ggplot2)
  year &lt;- 2005:2015
  variablea &lt;- 1000:1010
  variableb &lt;- 1010:1020
  df = data.frame(year, variablea, variableb)
  
  p &lt;- ggplot(df, aes(x = df$year)) +
    geom_line(aes(y = df$variablea, colour="variablea", linetype="longdash")) + 
    geom_line(aes(y = df$variableb, colour="variableb")) + 
    xlab("Year") +
    ylab("Value") + 
    scale_colour_manual("", breaks=c("variablea", "variableb")
                        , values=c("variablea"="red", "variableb"="blue")) + 
    scale_linetype_manual("", breaks=c("variablea", "variableb")
                        , values=c("longdash", "solid"))
  
  p
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Lx5lP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Lx5lP.png" alt="enter image description here"></a></p>
  
  <p>Notice that both lines appear as solid in the legend.</p>