title: Visualising interaction between two categorical predictors and continuous outcome with ribbon confidence intervals
body: <p>I am very new to R, so apologise in advance for a possible simple or obvious question.</p>
  <p>I am trying to graph an interaction between two categorical variables (A and I), which both have 2 levels (0 and 1), against one continuous variable (V). I would like V on the Y axes, A on the X axes and I as different lines on the graph. However, I would like to include 95% confidence intervals. I would like to use a ribbon style CI on the graph (like geom_ribbon produces). However, I cannot do this after identifying A and I as binary categorical variables in R. The only way I can figure out how to do it is leaving A as a continuous variable (see picture). The syntax I am using is below:</p>
  <pre><code>data$I &lt;- as.factor(data$I)
  data$A &lt;- as.factor(data$A)
  
  gp &lt;- ggplot(data=data, aes(x=A, y=V, colour=I)) 
  gp + geom_point() + stat_smooth(method=&quot;lm&quot;)
  </code></pre>
  <p>Though I did not set A as a categorical variable when producing the attached image.</p>
  <p><a href="https://i.stack.imgur.com/BMilE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BMilE.png" alt="enter image description here" /></a></p>