title: Plotting the overall trend using ggplot for longitudinal data
body: <p>I want to plot the overall trend for longitudinal data. I am using the <code>sleepstudy</code> data in <code>lme4</code> package to demonstrate my problem.</p>
  
  <pre><code> library("lme4")
   library("ggplot2")
      p1 &lt;- ggplot(data = sleepstudy, aes(x = Days, y = Reaction, group = Subject))
      p1 + geom_line() + geom_point(aes(col = Subject) ,size=2)
  </code></pre>
  
  <p>When i plot the longitudinal trajectories for each individual, I got this plot
  <a href="https://i.stack.imgur.com/X5jhU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/X5jhU.png" alt="enter image description here"></a></p>
  
  <p>Here I am interested in finding the overall trend based on all subjects. For an example based on the above plot we can see an upward trend in general.  In general this trend can be anything like linear, quadratic etc. Is this any way to plot this overall trend ?</p>
  
  <p>I tried this . But i got smoothed curves for each subject instead of getting the overall trend</p>
  
  <pre><code>p1  + geom_point() +  geom_smooth(method = "lm") 
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/EK25h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EK25h.png" alt="enter image description here"></a></p>
  
  <p>Can anyone help me figure this out ? </p>
  
  <p>Thank you </p>