title: How to create two different regression line based on factor for each facet? R, ggplot2
body: <p>I am trying to create two different lines based on exercise = 0 or exercise = 1 for each facet (by gender). The first code is without facet_wrap and the two lines based on gender are different. The second code is with facet_wrap and the two lines seem to be the same line. How can I change the code so that the two lines are different within each facet?</p>
  
  <pre><code>ggplot(cdc, aes(weight,wtdesire, color = exercise, group = 
  interaction(gender,exercise))) + geom_point(alpha = 1/5) + 
  geom_smooth(method = lm, aes(linetype=exercise))
  </code></pre>
  
  <p>produces: <a href="https://i.stack.imgur.com/sN1R1.png" rel="nofollow noreferrer">facet</a></p>
  
  <p>However, when I add facet_wrap the two lines for each facet seem to be the same.</p>
  
  <pre><code>ggplot(cdc, aes(weight,wtdesire, color = exercise, group = 
  interaction(gender,exercise))) + geom_point(alpha = 1/5) + 
  geom_smooth(method = lm, aes(linetype=exercise)) + facet_wrap(~gender)
  </code></pre>
  
  <p>produces: <a href="https://i.stack.imgur.com/fOEW3.png" rel="nofollow noreferrer">second</a></p>