title: R - ggplot with regression line per group doesnt work
body: <p>I am following the instructions <a href="http://www.sthda.com/english/wiki/ggplot2-scatter-plots-quick-start-guide-r-software-and-data-visualization" rel="nofollow noreferrer">here</a> to create a scatter plot between a predictor and response per group</p>
  
  <pre><code>require(data.table)
  require(ggplot2)
  
  group.nobs &lt;- 50
  group.beta0 &lt;- c(-1., 0., 1.)
  group.beta1 &lt;- c(0.8, 1.0, 1.2)
  
  predictor &lt;- rnorm(n = group.nobs)
  response &lt;- c(group.beta0[1] + group.beta1[1] * predictor + rnorm(sd = 0.1, n = group.nobs),
                group.beta0[2] + group.beta1[2] * predictor + rnorm(sd = 0.1, n = group.nobs),
                group.beta0[3] + group.beta1[3] * predictor + rnorm(sd = 0.1, n = group.nobs))
  
  
  df &lt;- data.table(group=c(rep(1,group.nobs),rep(2,group.nobs),rep(3,group.nobs)), x=predictor, y=response)
  
  ggplot(df, aes(x=x, y=y, color=group)) +
    geom_point() + 
    geom_smooth(method=lm, se=FALSE, fullrange=TRUE)
  </code></pre>
  
  <p>but there is only 1 regression line that's plotted </p>
  
  <p><a href="https://i.stack.imgur.com/87ooD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/87ooD.jpg" alt="ggplot scatter plot with regression line"></a></p>
  
  <p>I would like 3 regression lines for each group</p>
  
  <p>thanks for the help</p>